Merge lp:~openerp-dev/openobject-addons/6.1-opw-582922-msh into lp:openobject-addons/6.1

Proposed by Mohammed Shekha(Open ERP)
Status: Needs review
Proposed branch: lp:~openerp-dev/openobject-addons/6.1-opw-582922-msh
Merge into: lp:openobject-addons/6.1
Diff against target: 56 lines (+3/-15)
3 files modified
mail/res_partner.py (+0/-6)
product/pricelist.py (+3/-3)
project/res_partner.py (+0/-6)
To merge this branch: bzr merge lp:~openerp-dev/openobject-addons/6.1-opw-582922-msh
Reviewer Review Type Date Requested Status
OpenERP Core Team Pending
Review via email: mp+139901@code.launchpad.net

Description of the change

Hello,

Fixed the issue of Product UOM, unit price was calculated wrong due to wrong UOM when unit price is calculated from partner section of the form.

Demo :- Do the following configuration of product.

Product Type: Stockable, Procurement Method: Make to order, Supply method: Buy, Sale Price: 20, Cost Price: 10

Default unit of measure: kg, Purchase unit of measure: kg, Unit of sale: 100g(obviosuly smaller than reference and 10 time smaller),

Define supplier in product say for example 'abc' which has pricelist as 1 Qty = 10, the supplier abc uses Default purchase price list for Purchase pricelist so whenever we will create purchase order for that supplier Default purchase pricelist will be used, Default purchase pricelist has Produce listprices items which has Based on value = Partner section of the product form.

Now with this product configuration create request for quotation, select partner 'abc' and select product which we have created with above configuration, you will see there is unit price difference, for 1 kg if we have set 10 in supplier section then still it gives 100 as a unit price.

Reason :- All calculation goes well for price_get and price_get_multi in pricelist.py but while calculating price(by calling _compute_price method) we have passed product.uos_id.id, there should be uom of context if context contains uom, if there is uom in context that means price_get is called from sale or purchase product_id_onchange, we already set uom in context from product_id_onchange of sale/purchase, so we should consider uom of context.

One more thing here there is problem with product_id and tmpl_id, while calculating partner_where we have fired a query SELECT name FROM product_supplierinfo WHERE product_id = %s, here product_id of product_supplierinfo has relationship with product_template so there should be tmpl_id not product_id because id of product and id of template will not always be same, so changed that also.

I have added a video for reference at https://docs.google.com/file/d/0B035wZ_8-uAIYXF6VzU2eGFVdzA/edit?pli=1

Thanks.

To post a comment you must log in.
7101. By Mohammed Shekha(Open ERP)

[FIX]Refixed the issue of UOM, fixed stupid mistake in previous commit

Unmerged revisions

7101. By Mohammed Shekha(Open ERP)

[FIX]Refixed the issue of UOM, fixed stupid mistake in previous commit

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'mail/res_partner.py'
--- mail/res_partner.py 2012-12-12 15:48:10 +0000
+++ mail/res_partner.py 2012-12-20 06:39:23 +0000
@@ -28,12 +28,6 @@
28 _columns = {28 _columns = {
29 'emails': fields.one2many('mail.message', 'partner_id', 'Emails', readonly=True, domain=[('email_from','!=',False)]),29 'emails': fields.one2many('mail.message', 'partner_id', 'Emails', readonly=True, domain=[('email_from','!=',False)]),
30 }30 }
31
32 def copy(self, cr, uid, id, default=None, context=None):
33 if not default:
34 default = {}
35 default = dict(default, emails=[])
36 return super(res_partner, self).copy(cr, uid, id, default=default, context=context)
3731
38res_partner()32res_partner()
3933
4034
=== modified file 'product/pricelist.py'
--- product/pricelist.py 2012-01-31 13:36:57 +0000
+++ product/pricelist.py 2012-12-20 06:39:23 +0000
@@ -204,7 +204,7 @@
204204
205 if partner:205 if partner:
206 partner_where = 'base <> -2 OR %s IN (SELECT name FROM product_supplierinfo WHERE product_id = %s) '206 partner_where = 'base <> -2 OR %s IN (SELECT name FROM product_supplierinfo WHERE product_id = %s) '
207 partner_args = (partner, product_id)207 partner_args = (partner, tmpl_id)
208 else:208 else:
209 partner_where = 'base <> -2 '209 partner_where = 'base <> -2 '
210 partner_args = ()210 partner_args = ()
@@ -288,8 +288,8 @@
288 results['item_id'] = res['id']288 results['item_id'] = res['id']
289 if 'uom' in context and not uom_price_already_computed:289 if 'uom' in context and not uom_price_already_computed:
290 product = products_dict[product_id]290 product = products_dict[product_id]
291 uom = product.uos_id or product.uom_id291 uom = context['uom']
292 price = product_uom_obj._compute_price(cr, uid, uom.id, price, context['uom'])292 price = product_uom_obj._compute_price(cr, uid, uom, price, context['uom'])
293293
294 if results.get(product_id):294 if results.get(product_id):
295 results[product_id][pricelist_id] = price295 results[product_id][pricelist_id] = price
296296
=== modified file 'project/res_partner.py'
--- project/res_partner.py 2012-12-12 15:48:10 +0000
+++ project/res_partner.py 2012-12-20 06:39:23 +0000
@@ -28,12 +28,6 @@
28 _columns = {28 _columns = {
29 'task_ids': fields.one2many('project.task', 'partner_id', 'Tasks'),29 'task_ids': fields.one2many('project.task', 'partner_id', 'Tasks'),
30 }30 }
31
32 def copy(self, cr, uid, id, default=None, context=None):
33 if not default:
34 default = {}
35 default = dict(default, task_ids=[])
36 return super(res_partner, self).copy(cr, uid, id, default=default, context=context)
3731
38res_partner()32res_partner()
3933