[FIX] sale_margin: sale margin accuracy
Unit Price, Cost Price and Margin must have the same accuracy. opw:632511
This commit is contained in:
parent
67530c7b1d
commit
0d74dce709
|
@ -19,6 +19,7 @@
|
||||||
##############################################################################
|
##############################################################################
|
||||||
|
|
||||||
from openerp.osv import fields, osv
|
from openerp.osv import fields, osv
|
||||||
|
import openerp.addons.decimal_precision as dp
|
||||||
|
|
||||||
class sale_order_line(osv.osv):
|
class sale_order_line(osv.osv):
|
||||||
_inherit = "sale.order.line"
|
_inherit = "sale.order.line"
|
||||||
|
@ -52,13 +53,13 @@ class sale_order_line(osv.osv):
|
||||||
for line in self.browse(cr, uid, ids, context=context):
|
for line in self.browse(cr, uid, ids, context=context):
|
||||||
res[line.id] = 0
|
res[line.id] = 0
|
||||||
if line.product_id:
|
if line.product_id:
|
||||||
res[line.id] = round(line.price_subtotal - ((line.purchase_price or line.product_id.standard_price) * line.product_uos_qty), 2)
|
res[line.id] = line.price_subtotal - ((line.purchase_price or line.product_id.standard_price) * line.product_uos_qty)
|
||||||
return res
|
return res
|
||||||
|
|
||||||
_columns = {
|
_columns = {
|
||||||
'margin': fields.function(_product_margin, string='Margin',
|
'margin': fields.function(_product_margin, string='Margin', digits_compute= dp.get_precision('Product Price'),
|
||||||
store = True),
|
store = True),
|
||||||
'purchase_price': fields.float('Cost Price', digits=(16,2))
|
'purchase_price': fields.float('Cost Price', digits_compute= dp.get_precision('Product Price'))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -83,7 +84,7 @@ class sale_order(osv.osv):
|
||||||
'margin': fields.function(_product_margin, string='Margin', help="It gives profitability by calculating the difference between the Unit Price and the cost price.", store={
|
'margin': fields.function(_product_margin, string='Margin', help="It gives profitability by calculating the difference between the Unit Price and the cost price.", store={
|
||||||
'sale.order.line': (_get_order, ['margin', 'purchase_price'], 20),
|
'sale.order.line': (_get_order, ['margin', 'purchase_price'], 20),
|
||||||
'sale.order': (lambda self, cr, uid, ids, c={}: ids, ['order_line'], 20),
|
'sale.order': (lambda self, cr, uid, ids, c={}: ids, ['order_line'], 20),
|
||||||
}),
|
}, digits_compute= dp.get_precision('Product Price')),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue