美好的一天!我在Odoo的按钮中遇到问题我在XML中创建了Treeview,其中有一个按钮,用于获取所选记录的ID,这是一个示例代码
XML
<notebook>
<page string ="Employee's Payroll">
<data>
<field name="payroll_main_id" string ="" attrs="{'readonly':[('state', '!=', 'draft')]}" >
<tree create = "false" editable="bottom/top">
<field name ="id" readonly="1" invisible="0"/>
<field name ="name" readonly="1"/>
<field name ="employee_id" readonly="1" />
<button name = "%(action_incentive_wiz_breakdown)d"
string ="Breakdown"
type = "action"
context = "{'default_payroll_detail_id': id,
'default_other_type': 1}"/>
<field name ="tardiness" />
</tree>
</field>
</data>
</page>
</notebook>
按钮将调用向导表单并且需要所选的ID(当按下按钮时)记录,问题是在向导中引用时始终使用的最后一个ID(按钮单击的第一个ID) )。有人可以帮我解决这个问题,谢谢。
继承人向导形式 XML
<record id="view_incentive_wiz_breakdown" model="ir.ui.view">
<field name="name">payroll.incentive.main.wiz.form</field>
<field name="model">payroll.incentive.main.wiz</field>
<field name="arch" type="xml">
<form string="Incentive Breakdown" create="false" edit="false">
<sheet>
<group string ="Information">
<field name="other_type" readonly="1"/>
<field name="payroll_detail_id" />
<field name="name" />
</group>
<notebook>
<page string ="Breakdown">
<data>
<field name="incentive_ids">
<tree create = "false" editable="bottom/top">
<field name="name" readonly="1"/>
<field name="amount"/>
</tree>
</field>
</data>
</page>
</notebook>
</sheet>
<footer>
<button name="updateReliever" string="Save" type="object" class="oe_highlight"/> or
<button string="Cancel" special="cancel" class="oe_link"/>
</footer>
</form>
</field>
</record>
<record id="action_incentive_wiz_breakdown" model="ir.actions.act_window">
<field name="name">Reliever Attendance</field>
<field name="type">ir.actions.act_window</field>
<field name="res_model">payroll.incentive.main.wiz</field>
<field name="view_type">form</field>
<field name="view_mode">form</field>
<field name="target">new</field>
<field name="nodestroy">True</field>
</record>