跳至內容
選單
此問題已被標幟
2557 瀏覽次數

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.

相關帖文 回覆 瀏覽次數 活動
2
1月 24
5432
0
6月 23
2028
1
12月 22
3339
1
4月 19
6204
2
7月 25
3820