Ir al contenido
Menú
Se marcó esta pregunta
1 Responder
39215 Vistas

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
Descartar
Mejor respuesta

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
Descartar
Publicaciones relacionadas Respuestas Vistas Actividad
3
may 25
3279
0
mar 15
4807
0
jul 24
1173
0
ago 18
6919
2
dic 16
9586