Merge lp:~openerp-dev/openobject-addons/6.0-opw-591881-msh into lp:openobject-addons/6.0

Proposed by Mohammed Shekha(Open ERP)
Status: Needs review
Proposed branch: lp:~openerp-dev/openobject-addons/6.0-opw-591881-msh
Merge into: lp:openobject-addons/6.0
Diff against target: 48 lines (+7/-9)
2 files modified
product/product.py (+2/-1)
purchase/purchase.py (+5/-8)
To merge this branch: bzr merge lp:~openerp-dev/openobject-addons/6.0-opw-591881-msh
Reviewer Review Type Date Requested Status
Vinay Rana (OpenERP) Pending
Naresh(OpenERP) Pending
Review via email: mp+167479@code.launchpad.net

Description of the change

Hello,

Fixed the issue of uom conversion, conversion of supplier quantity should from supplier uom to purchase uom.

Demo:- Create one test product with Default unit of measure cm and Purchase unit of measure km, also define the supplier for product with supplier unit of measure to km and minimum quantity 1.

Now ask for product that is create procurement order for this product with 100cm and check the product quantity in purchase order, conversion is wrong, the method _calc_qty of product_supplier_info object converts quantity from supplier UOM to default UOM it should be supplier UOM to Purchase UOM.

One more scenario is remove minimum quantity from supplier and then create procurement order, still conversion issue.

So fixed this issue and used po_uom_id, check version 6.1 or 7.0 we use supplier uom as po_uom by default and made that supplier uom field readonly so there is no need of conversion from supplier to po, the quantity should always be converted to purchase UOM.

Thanks.

To post a comment you must log in.

Unmerged revisions

5478. By Mohammed Shekha<email address hidden>

[FIX]Fixed the issue of uom conversion, conversion of supplier quantity should from supplier uom to purchase uom.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'product/product.py'
2--- product/product.py 2012-03-30 08:53:02 +0000
3+++ product/product.py 2013-06-05 08:40:50 +0000
4@@ -712,7 +712,8 @@
5 for field in fields:
6 result[supplier_info.id] = {field:False}
7 if supplier_info.product_uom.id:
8- qty = product_uom_pool._compute_qty(cr, uid, supplier_info.product_uom.id, supplier_info.min_qty, to_uom_id=supplier_info.product_id.uom_id.id)
9+ #conversion should from supplier uom to po_uom_id
10+ qty = product_uom_pool._compute_qty(cr, uid, supplier_info.product_uom.id, supplier_info.min_qty, to_uom_id=supplier_info.product_id.uom_po_id.id)
11 else:
12 qty = supplier_info.min_qty
13 result[supplier_info.id]['qty'] = qty
14
15=== modified file 'purchase/purchase.py'
16--- purchase/purchase.py 2012-06-29 14:14:29 +0000
17+++ purchase/purchase.py 2013-06-05 08:40:50 +0000
18@@ -811,25 +811,22 @@
19 qty = max(qty,seller_qty)
20
21 price = pricelist_obj.price_get(cr, uid, [pricelist_id], procurement.product_id.id, qty, partner_id, {'uom': uom_id})[pricelist_id]
22+ price_unit_precision = self.pool.get('decimal.precision').precision_get(cr, uid, 'Purchase Price')
23+ price = rounding(price, 10**-price_unit_precision)
24
25 newdate = datetime.strptime(procurement.date_planned, '%Y-%m-%d %H:%M:%S')
26 newdate = (newdate - relativedelta(days=company.po_lead)) - relativedelta(days=seller_delay)
27
28- res_onchange = po_line_obj.product_id_change(cr, uid, ids, pricelist_id, procurement.product_id.id, qty, uom_id,
29- partner_id, time.strftime('%Y-%m-%d'), fiscal_position=fiscal_position, date_planned=datetime.now() + relativedelta(days=seller_delay or 0.0),
30- name=procurement.name, price_unit=procurement.product_id.list_price, notes=procurement.product_id.description_purchase)
31-
32 #Passing partner_id to context for purchase order line integrity of Line name
33 context.update({'lang': partner.lang, 'partner_id': partner_id})
34
35 product = prod_obj.browse(cr, uid, procurement.product_id.id, context=context)
36-
37 line = {
38 'name': product.partner_ref,
39- 'product_qty': res_onchange['value']['product_qty'],
40+ 'product_qty': qty,
41 'product_id': procurement.product_id.id,
42- 'product_uom': res_onchange['value']['product_uom'],
43- 'price_unit': res_onchange['value']['price_unit'],
44+ 'product_uom': uom_id,
45+ 'price_unit': price or 0.0,
46 'date_planned': newdate.strftime('%Y-%m-%d %H:%M:%S'),
47 'move_dest_id': res_id,
48 'notes': product.description_purchase,