In v9 I'm trying to add a smart button to the partner form. I copied the code from the sale module, at https://github.com/odoo/odoo/blob/9.0/addons/sale/res_partner_view.xml#L38
The original code is:
<record id="res_partner_view_buttons" model="ir.ui.view"> |
<field name="name">res.partner.view.buttons</field> |
<field name="model">res.partner</field> |
<field name="inherit_id" ref="base.view_partner_form" /> |
<field name="priority" eval="20"/> |
<field name="groups_id" eval="[(4, ref('base.group_sale_salesman'))]"/> |
<field name="arch" type="xml"> |
<div name="button_box" position="inside"> |
<button class="oe_stat_button" type="action" name="%(sale.act_res_partner_2_sale_order)d" |
attrs="{'invisible': [('customer', '=', False)]}" |
icon="fa-usd"> |
<field string="Sales" name="sale_order_count" widget="statinfo"/> |
</button> |
</div> |
</field> |
</record> |
I fitted it to suit my needs
<record id="res_partner_view_buttons" model="ir.ui.view">
<field name="name">res.partner.view.buttons</field>
<field name="model">res.partner</field>
<field name="inherit_id" ref="base.view_partner_form" />
<field name="priority" eval="20"/>
<field name="arch" type="xml">
<div name="buttons" position="inside"
<button class="oe_inline oe_stat_button" type="action" string="Cycles"
name="medical_report_basic.act_res_partner_2_cycle"
icon="fa-repeat" help="Manage patient's cycles">
</button>
</div>
</field>
</record>
The system keeps complaining that
Element '<div name="buttons">' cannot be located in parent view
I changed it to
<xpath expr="(//sheet/div)[last()]" position="before">
<div class="oe_right oe_button_box" name="cycle_buttons">
<button class="oe_inline oe_stat_button" type="action" string="Cycles"
name="medical_report_basic.act_res_partner_2_cycle"
icon="fa-repeat" help="Manage patient's cycles">
</button>
</div>
</xpath>
And it is working fine - but it is a weird solution.
Why is the sale module code not working for me?