Skip to Content
Menu
This question has been flagged
1 Odpoveď
39435 Zobrazenia

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?    

Avatar
Zrušiť
Best Answer

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)
Avatar
Zrušiť
Related Posts Replies Zobrazenia Aktivita
3
máj 25
3443
0
mar 15
4952
0
júl 24
1296
0
aug 18
7103
2
dec 16
9739