Skip to Content
Меню
Вам необхідно зареєструватися, щоб взаємодіяти зі спільнотою.
Це запитання позначене
1 Відповісти
39364 Переглядів

I am doing:

line.sale_margin_percent = 100-((line.purchase_price*100)/line.price_unit)

Whe line.price_unit is 0 I get:

ZeroDivisionError: float division by zero

Which is the regular way to avoid that in python/odoo?    

Аватар
Відмінити
Найкраща відповідь

Hello E.M

This will occur when price_unit is Zero

You can add condition before doing this

if line.price_unit > 0:
     line.sale_margin_percent = 100-((line.purchase_price*100)/line.price_unit)
Аватар
Відмінити
Related Posts Відповіді Переглядів Дія
3
трав. 25
3376
0
бер. 15
4897
0
лип. 24
1262
0
серп. 18
7042
2
груд. 16
9675