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?
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
|
5353 | |||
|
0
3월 15
|
6638 | |||
|
0
7월 24
|
2578 | |||
|
0
8월 18
|
8689 | |||
|
2
12월 16
|
11795 |
1. Use the live chat to ask your questions.
2. The operator answers within a few minutes.