İçereği Atla
Menü
Bu soru işaretlendi
1 Cevapla
39431 Görünümler

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
Vazgeç
En İyi Yanıt

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
Vazgeç
İlgili Gönderiler Cevaplar Görünümler Aktivite
3
May 25
3441
0
Mar 15
4951
0
Tem 24
1295
0
Ağu 18
7102
2
Ara 16
9727