c2c-oerpscenario team mailing list archive
-
c2c-oerpscenario team
-
Mailing list archive
-
Message #20099
[Bug 741612] Re: Sale_margin break if discount= 100%
Hi !,
First of all I forgot some place where you need to correct the computation.
Then, I agree, what if pa is 0 ;) ! I report this bug a bit too fast...
Here is the expected solution I think.
Regards,
Joël
=== modified file 'sale_margin/object/sale_margin.py'
--- sale_margin/object/sale_margin.py 2011-03-24 11:14:36 +0000
+++ sale_margin/object/sale_margin.py 2011-03-25 08:07:28 +0000
@@ -55,7 +55,10 @@
pa = (std_price*product_uom_qty)
margin = round(pv -pa,int(config['price_accuracy']))
res['value']['margin'] = margin
- res['value']['marginpourcent'] = (((pv-pa)/pv)*100)
+ marginpourcent = 0.0
+ if pa <> 0.0:
+ marginpourcent = ((pv / pa) - 1) * 100
+ res['value']['marginpourcent'] = marginpourcent
res['value']['purchase_price'] = std_price
return res
@@ -77,7 +80,10 @@
pa = (std_price*product_uom_qty)
margin = round(pv -pa,int(config['price_accuracy']))
res['value']['margin'] = margin
- res['value']['marginpourcent'] = (((pv-pa)/pv)*100)
+ marginpourcent = 0.0
+ if pa <> 0.0:
+ marginpourcent = ((pv / pa) - 1) * 100
+ res['value']['marginpourcent'] = marginpourcent
res['value']['purchase_price'] = std_price
return res
@@ -106,7 +112,10 @@
pa = (std_price*res['value']['product_uos_qty'])
margin = round(pv - pa,int(config['price_accuracy']))
res['value']['margin'] = margin
- res['value']['marginpourcent'] = (((pv-pa)/pv)*100)
+ marginpourcent = 0.0
+ if pa <> 0.0:
+ marginpourcent = ((pv / pa) - 1) * 100
+ res['value']['marginpourcent'] = marginpourcent
res['value']['purchase_price'] = std_price
return res
--
You received this bug notification because you are a member of C2C
OERPScenario, which is subscribed to the OpenERP Project Group.
https://bugs.launchpad.net/bugs/741612
Title:
Sale_margin break if discount= 100%
Status in OpenERP Modules (addons):
New
Bug description:
Hi,
Install sale_margin, make a 100% discount, hit tab => float division
by 0 !!!
You must compute the margin like this: ((pv / pa) - 1) * 100 instead
of (((pv-pa)/pv)*100)
Thanks to fix... Patch given here:
=== modified file 'sale_margin/object/sale_margin.py'
--- sale_margin/object/sale_margin.py 2010-06-11 10:23:30 +0000
+++ sale_margin/object/sale_margin.py 2011-03-24 11:01:32 +0000
@@ -77,7 +77,7 @@
pa = (std_price*product_uom_qty)
margin = round(pv -pa,int(config['price_accuracy']))
res['value']['margin'] = margin
- res['value']['marginpourcent'] = (((pv-pa)/pv)*100)
+ res['value']['marginpourcent'] = ((pv / pa) - 1) * 100
res['value']['purchase_price'] = std_price
return res
Regards,
Joël
References