我正在使用Openerp 7,我需要在树视图标题区域(创建或导入旁边)上调用自定义按钮。是否可以这样做?
这就是我需要移动的按钮的方式;
<record model="ir.ui.view" id="edit_roster_substitution_form">
<field name="name">leave.score.card.form</field>
<field name="model">leave.score.card</field>
<field name="arch" type="xml">
<form string="Leave Score Card" version="7.0">
<sheet>
<button string="Generate" type="object" name="populate_values" class="oe_highlight"/>
</sheet>
</form>
</field>
</record>
树状视图,
<record model="ir.ui.view" id="view_leave_score_card_tree">
<field name="name">leave.score.card.tree</field>
<field name="model">leave.score.card</field>
<field name="arch" type="xml">
<tree string="Leave Score Card To the Date" colors="red:available_medical < 0.0; red:available_casual < 0.0">
<field name="employee_id" />
<field name="category_id" />
<field name="taken_medical" />
<field name="taken_casual" />
<field name="taken_annual" />
<field name="taken_spc" />
<field name="available_medical" />
<field name="available_casual" />
<field name="available_annual" />
<field name="available_spc" />
<field name="sec_id" invisible="1" />
<field name="division_id" invisible="1" />
<field name="departmnt_id" invisible="1" />
<field name="comp_id" invisible="1" />
<field name="total_taken_leaves" invisible="1"/>
</tree>
</field>
</record>
这是我的操作窗口和菜单调用
<record id="open_leave_score_card" model="ir.actions.act_window">
<field name="name">Leave Score Card To the Date</field>
<field name="type">ir.actions.act_window</field>
<field name="res_model">leave.score.card</field>
<field name="view_type">form</field>
<field name="view_mode">tree,graph,form</field>
<field name="view_id" eval="view_leave_score_card_tree"/>
<field name="search_view_id" ref="view_leave_score_card_search"/>
</record>
<menuitem name="Leave Score Card" action="open_leave_score_card" id="menu_open_view_leave_score_card" parent="base.menu_reporting_dashboard" />
这是我的功能
def populate_values(self, cr, uid, ids, context={}):
result = {'value': {}}
today = datetime.datetime.now()
tt=today.date()
emps=self.pool.get('hr.employee').search(cr, uid, [('current_status','=','active')], context=context)
if emps:
for employees in emps:
#result['value']['employee_id'] = employees
print employees
holiday_obj=self.pool.get('hr.holidays')
holiday_emps_allocate=holiday_obj.search(cr, uid, [('employee_id','=',employees),('type','=','add'),('state','=','validate')], context=context)
holiday_emps_taken=holiday_obj.search(cr, uid, [('employee_id','=',employees),('type','=','remove'),('state','=','validate')], context=context)
.
.
.
我期待的是
是否可以这样做?
[1]: https://i.stack.imgur.com/TePJy.jpg
[2]: https://i.stack.imgur.com/9BFVG.jpg