تخطي للذهاب إلى المحتوى
القائمة
لقد تم الإبلاغ عن هذا السؤال
2552 أدوات العرض

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
يناير 24
5424
0
يونيو 23
2024
1
ديسمبر 22
3336
1
أبريل 19
6202
2
يوليو 25
3814