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?
Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:
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)
Create an account today to enjoy exclusive features and engage with our awesome community!
Registrácia| Related Posts | Replies | Zobrazenia | Aktivita | |
|---|---|---|---|---|
|
3
máj 25
|
4236 | |||
|
0
mar 15
|
5582 | |||
|
0
júl 24
|
1813 | |||
|
0
aug 18
|
7776 | |||
|
2
dec 16
|
10516 |
1. Use the live chat to ask your questions.
2. The operator answers within a few minutes.