my bython code:
class AccountMoveLine(models.Model):
_inherit = "account.move.line"
area = fields.Float(compute="caluclate_area",string="Area",store=True,default=1.0)
width = fields.Float(string="Width",default=1.0)
hight = fields.Float(string="Hight",default=1.0)
length = fields.Float(string="Length",default=1.0)
meter_sq = fields.Float(string="Meter squer price")
@api.depends('width', 'length', 'quantity')
def caluclate_area(self):
for x in self:
x.area = x.width * x.length * x.quantity
x.price_subtotal = x.area * x.hight * x.price_unit
xml code:
<record id = "account_move_line_custom" model ="ir.ui.view" >
<field name = "name">account.move.custom</field>
<field name = "model">account.move</field>
<field name = "inherit_id" ref="account.view_move_form" />
<field name = "arch" type = "xml" >
<xpath expr="//field[@name='invoice_line_ids']/tree/field[@name='quantity']" position="before" >
<field name="area" />
<field name="width"/>
<field name="length"/>
<field name="hight"/>
</xpath>
<xpath expr="//field[@name='line_ids']/tree/field[@name='account_id']" position="after" >
<field name="area" invisible="1"/>
<field name="width" invisible="1"/>
<field name="length" invisible="1"/>
<field name="hight" invisible="1"/>
</xpath>
</field>
</record>