Skip to Content
Menu
Dette spørgsmål er blevet anmeldt
1 Svar
39427 Visninger

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
Kassér
Bedste svar

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
Kassér
Related Posts Besvarelser Visninger Aktivitet
3
maj 25
3438
0
mar. 15
4950
0
jul. 24
1290
0
aug. 18
7101
2
dec. 16
9722