Merge lp:~openerp-dev/openobject-addons/7.0-opw-603584-acl into lp:openobject-addons/7.0

Proposed by Anaël Closson (openerp)
Status: Needs review
Proposed branch: lp:~openerp-dev/openobject-addons/7.0-opw-603584-acl
Merge into: lp:openobject-addons/7.0
Diff against target: 35 lines (+7/-5)
1 file modified
sale_margin/sale_margin.py (+7/-5)
To merge this branch: bzr merge lp:~openerp-dev/openobject-addons/7.0-opw-603584-acl
Reviewer Review Type Date Requested Status
OpenERP Core Team Pending
Review via email: mp+211684@code.launchpad.net
To post a comment you must log in.

Unmerged revisions

9851. By Anaël Closson (openerp)

[FIX] OPW 603584 : Incorrect calculation of Cost Price of sales order line when selecting different UoM

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'sale_margin/sale_margin.py'
2--- sale_margin/sale_margin.py 2012-12-19 01:25:10 +0000
3+++ sale_margin/sale_margin.py 2014-03-19 09:36:50 +0000
4@@ -23,18 +23,20 @@
5 class sale_order_line(osv.osv):
6 _inherit = "sale.order.line"
7
8- def product_id_change(self, cr, uid, ids, pricelist, product, qty=0,
9+ def product_id_change(self, cr, uid, ids, pricelist, product_id, qty=0,
10 uom=False, qty_uos=0, uos=False, name='', partner_id=False,
11 lang=False, update_tax=True, date_order=False, packaging=False, fiscal_position=False, flag=False, context=None):
12- res = super(sale_order_line, self).product_id_change(cr, uid, ids, pricelist, product, qty=qty,
13+ res = super(sale_order_line, self).product_id_change(cr, uid, ids, pricelist, product_id, qty=qty,
14 uom=uom, qty_uos=qty_uos, uos=uos, name=name, partner_id=partner_id,
15 lang=lang, update_tax=update_tax, date_order=date_order, packaging=packaging, fiscal_position=fiscal_position, flag=flag, context=context)
16 if not pricelist:
17 return res
18 frm_cur = self.pool.get('res.users').browse(cr, uid, uid).company_id.currency_id.id
19 to_cur = self.pool.get('product.pricelist').browse(cr, uid, [pricelist])[0].currency_id.id
20- if product:
21- purchase_price = self.pool.get('product.product').browse(cr, uid, product).standard_price
22+ if product_id:
23+ product = self.pool.get('product.product').browse(cr, uid, product_id)
24+ frm_uom = product.uos_id.id or product.uom_id.id
25+ purchase_price = self.pool.get('product.uom')._compute_price(cr, uid, frm_uom, product.standard_price, uom)
26 price = self.pool.get('res.currency').compute(cr, uid, frm_cur, to_cur, purchase_price, round=False)
27 res['value'].update({'purchase_price': price})
28 return res
29@@ -84,4 +86,4 @@
30
31 sale_order()
32
33-# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
34\ No newline at end of file
35+# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:1;2802;0c