跳至内容
菜单
此问题已终结
1 回复
39404 查看

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?    

形象
丢弃
最佳答案

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)
形象
丢弃
相关帖文 回复 查看 活动
3
5月 25
3411
0
3月 15
4939
0
7月 24
1282
0
8月 18
7070
2
12月 16
9703