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

I've created 2 new margin custom fields:

x_studio_total_margen_2 in sale.order.line that calculates a new margin from other costs.

x_studio_margen_2 in sale.order that is supposed to be the sum of every x_studio_total_margen_2 line added by the new formula:

for record in self:
    total = 0
    for line in record.order_line:
        total += line.x_studio_total_margen_2
    record['x_studio_margen_2'] += total

And it does the sum but it's not working well because it only makes a sum when I would like to have a correction update. For example:

If I have a product that costs 2€ and the sell price_unit is 6€ I will have a x_studio_margen_2 = 4€ but if I decide to change the price_unit to 5€due to whatever, x_studio_margen_2 is not going to be 3€ but the sum of the last x_studio_margen_2 = 4 + the new margin = 3, so the updated margin will be 7€ while it's supposed to be 3€.

Same happens when if I delete a product, x_studio_margen_2 doesn't changes, it's going to be the last number.

How can I fix it??

I know where the problem is but I don't get a solution.

Thank you!


อวตาร
ละทิ้ง

First avoid study

ผู้เขียน

I don't get if you mean that I'm not working on solving this by myself or if you mean to avoid Studio app from Odoo.

Related Posts ตอบกลับ มุมมอง กิจกรรม
Merge Same Item in Sale Order Line แก้ไขแล้ว
2
ม.ค. 24
5492
0
มิ.ย. 23
2069
1
ธ.ค. 22
3418
1
เม.ย. 19
6248
2
ก.ค. 25
3874