Skip to Content
Menu
Musisz się zarejestrować, aby móc wchodzić w interakcje z tą społecznością.
To pytanie dostało ostrzeżenie
1 Odpowiedz
39597 Widoki

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?    

Awatar
Odrzuć
Najlepsza odpowiedź

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)
Awatar
Odrzuć
Powiązane posty Odpowiedzi Widoki Czynność
3
maj 25
3661
0
mar 15
5131
0
lip 24
1407
0
sie 18
7262
2
gru 16
9917