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
=== modified file 'product/product.py'
--- product/product.py 2012-03-30 08:53:02 +0000
+++ product/product.py 2013-06-05 08:40:50 +0000
@@ -712,7 +712,8 @@
712 for field in fields:712 for field in fields:
713 result[supplier_info.id] = {field:False}713 result[supplier_info.id] = {field:False}
714 if supplier_info.product_uom.id:714 if supplier_info.product_uom.id:
715 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)715 #conversion should from supplier uom to po_uom_id
716 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)
716 else:717 else:
717 qty = supplier_info.min_qty718 qty = supplier_info.min_qty
718 result[supplier_info.id]['qty'] = qty719 result[supplier_info.id]['qty'] = qty
719720
=== modified file 'purchase/purchase.py'
--- purchase/purchase.py 2012-06-29 14:14:29 +0000
+++ purchase/purchase.py 2013-06-05 08:40:50 +0000
@@ -811,25 +811,22 @@
811 qty = max(qty,seller_qty)811 qty = max(qty,seller_qty)
812812
813 price = pricelist_obj.price_get(cr, uid, [pricelist_id], procurement.product_id.id, qty, partner_id, {'uom': uom_id})[pricelist_id]813 price = pricelist_obj.price_get(cr, uid, [pricelist_id], procurement.product_id.id, qty, partner_id, {'uom': uom_id})[pricelist_id]
814 price_unit_precision = self.pool.get('decimal.precision').precision_get(cr, uid, 'Purchase Price')
815 price = rounding(price, 10**-price_unit_precision)
814816
815 newdate = datetime.strptime(procurement.date_planned, '%Y-%m-%d %H:%M:%S')817 newdate = datetime.strptime(procurement.date_planned, '%Y-%m-%d %H:%M:%S')
816 newdate = (newdate - relativedelta(days=company.po_lead)) - relativedelta(days=seller_delay)818 newdate = (newdate - relativedelta(days=company.po_lead)) - relativedelta(days=seller_delay)
817819
818 res_onchange = po_line_obj.product_id_change(cr, uid, ids, pricelist_id, procurement.product_id.id, qty, uom_id,
819 partner_id, time.strftime('%Y-%m-%d'), fiscal_position=fiscal_position, date_planned=datetime.now() + relativedelta(days=seller_delay or 0.0),
820 name=procurement.name, price_unit=procurement.product_id.list_price, notes=procurement.product_id.description_purchase)
821
822 #Passing partner_id to context for purchase order line integrity of Line name820 #Passing partner_id to context for purchase order line integrity of Line name
823 context.update({'lang': partner.lang, 'partner_id': partner_id})821 context.update({'lang': partner.lang, 'partner_id': partner_id})
824822
825 product = prod_obj.browse(cr, uid, procurement.product_id.id, context=context)823 product = prod_obj.browse(cr, uid, procurement.product_id.id, context=context)
826
827 line = {824 line = {
828 'name': product.partner_ref,825 'name': product.partner_ref,
829 'product_qty': res_onchange['value']['product_qty'],826 'product_qty': qty,
830 'product_id': procurement.product_id.id,827 'product_id': procurement.product_id.id,
831 'product_uom': res_onchange['value']['product_uom'],828 'product_uom': uom_id,
832 'price_unit': res_onchange['value']['price_unit'],829 'price_unit': price or 0.0,
833 'date_planned': newdate.strftime('%Y-%m-%d %H:%M:%S'),830 'date_planned': newdate.strftime('%Y-%m-%d %H:%M:%S'),
834 'move_dest_id': res_id,831 'move_dest_id': res_id,
835 'notes': product.description_purchase,832 'notes': product.description_purchase,