Skip to Content
Menu
This question has been flagged
1 Odpoveď
2508 Zobrazenia

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>

Avatar
Zrušiť
Best Answer

If it has not solved you can try this

@api.depens('width', 'hight', 'quantity', 'length', 'price_unit')

Avatar
Zrušiť
Related Posts Replies Zobrazenia Aktivita
1
nov 24
1369
1
apr 23
2714
7
feb 23
9285
0
jan 23
1540
0
sep 22
1810