コンテンツへスキップ
メニュー
この質問にフラグが付けられました
1 返信
2507 ビュー

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>

アバター
破棄
最善の回答

If it has not solved you can try this

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

アバター
破棄
関連投稿 返信 ビュー 活動
1
11月 24
1369
1
4月 23
2714
7
2月 23
9285
0
1月 23
1540
0
9月 22
1810