I've tried Odoo 9 and want to replace the "Total" field = amount_total with a new field which is the result of some addition of field content (sum_of_total) with XPath expression but it's failing and not returning any result.
Here is my XML code :
<openerp>
<data>
<record id="purchase_order_form_training1" model="ir.ui.view">
<field name="name">purchase.order.form1</field>
<field name="model">purchase.order</field>
<field name="inherit_id" ref="purchase.purchase_order_form"/>
<field name="arch" type="xml">
<field name="amount_tax" position="after">
<field name="down_payment" widget="monetary" options="{'currency_field':'currency_id'}"/>
</field>
<xpath expr="form1/sheet/page/group/field[@name='amount_total']" position="replace">
<field name="sum_of_total"/>
</xpath>
</field>
</record>
</data>
</openerp>
The odoo log didn't show me any syntactical error. Can anyone help me to identify the root cause?
Refer below to understand how sum_of_total is getting initialized
from openerp import models, fields, api, _
class purchase_order(models.Model):
_inherit = "purchase.order"
@api.one
@api.depends('down_payment', 'amount_total')
def get_total_after_dp(self):
dp = self.down_payment
tot = selt.amount_total
tota = tot + dp
self.sum_of_total = tota
sum_of_total = fields.Float('Total Amount',
compute='get_total_after_dp')
down_payment = fields.Float('Down Payment')
There is no form1
in the purchase order form view.
try this:
<xpath expr="form/sheet/notebook/page/group/field[@name='amount_total']" position="replace">
<field name="sum_of_total"/>
</xpath>