Skip to Content
Menú
This question has been flagged
1 Respondre
39399 Vistes

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
Descartar
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
Descartar
Related Posts Respostes Vistes Activitat
3
de maig 25
3410
0
de març 15
4938
0
de jul. 24
1282
0
d’ag. 18
7070
2
de des. 16
9702