Se rendre au contenu
Menu
Cette question a été signalée
1 Répondre
39030 Vues

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
Ignorer
Meilleure réponse

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
Ignorer
Publications associées Réponses Vues Activité
3
mai 25
3064
0
mars 15
4664
0
juil. 24
1064
0
août 18
6733
2
déc. 16
9369