Skip to Content
मेन्यू
This question has been flagged
1 Reply
39502 Views

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
Discard
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
Discard
Related Posts Replies Views Activity
3
मई 25
3560
0
मार्च 15
5022
0
जुल॰ 24
1335
0
अग॰ 18
7192
2
दिस॰ 16
9836