Přejít na obsah
Menu
You need to be registered to interact with the community.
This question has been flagged
1 Odpovědět
39388 Zobrazení

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šit
Nejlepší odpověď

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šit
Related Posts Odpovědi Zobrazení Aktivita
3
kvě 25
3399
0
bře 15
4931
0
čvc 24
1277
0
srp 18
7060
2
pro 16
9697