Skip to Content
Menu
This question has been flagged
1 Atsakyti
39505 Rodiniai

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?    

Portretas
Atmesti
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)
Portretas
Atmesti
Related Posts Replies Rodiniai Veikla
3
geg. 25
3562
0
kov. 15
5027
0
liep. 24
1337
0
rugp. 18
7193
2
gruod. 16
9841