Skip to Content
เมนู
คุณต้องลงทะเบียนเพื่อโต้ตอบกับคอมมูนิตี้
คำถามนี้ถูกตั้งค่าสถานะ
1 ตอบกลับ
2379 มุมมอง

Hello guys ,
I have this field that calculate the results of two other fields
"x_totalunity = product_uom_qty * x_unitparcarton"
What i want is that i can be able to put also a value in x_totalunity and product_uom_qty changes ( product_uom_qty = x_totalunity / x_unitparcarton) which does not work
this is my code :

@api.depends('product_uom_qty', 'discount', 'price_unit', 'tax_id' , 'x_unitparcarton' )
def _compute_amount(self):
"""
Compute the amounts of the SO line.
"""
for line in self:

line.x_totalunity = line.product_uom_qty * line.x_unitparcarton


x_totalunity = fields.Float(compute='_compute_amount', string='Total unitéé', readonly=False, store=True , required=True, copy=True)

อวตาร
ละทิ้ง
คำตอบที่ดีที่สุด

Hi,

Just remove store=True and Try it

Otherwise follow below code

@api.depends('product_uom_qty', 'discount', 'price_unit', 'tax_id', 'x_unitparcarton')
def _compute_amount(self):
for line in self:
line.x_totalunity = line.product_uom_qty * line.x_unitparcarton
(or)
line.update({'x_totalunity': line.product_uom_qty * line.x_unitparcarton})


x_totalunity = fields.Float(compute='_compute_amount', string='Total unitéé', required=True, copy=True)


Thanks

อวตาร
ละทิ้ง
Related Posts ตอบกลับ มุมมอง กิจกรรม
2
ส.ค. 18
4395
2
เม.ย. 21
17050
0
พ.ค. 18
2279
0
มี.ค. 25
1319
4
เม.ย. 24
174168