Merge lp:~openerp-dev/openobject-addons/6.0-opw-574271-skh into lp:openobject-addons/6.0

Proposed by Somesh Khare
Status: Approved
Approved by: Naresh(OpenERP)
Approved revision: 5217
Proposed branch: lp:~openerp-dev/openobject-addons/6.0-opw-574271-skh
Merge into: lp:openobject-addons/6.0
Diff against target: 48 lines (+8/-6)
1 file modified
purchase/purchase.py (+8/-6)
To merge this branch: bzr merge lp:~openerp-dev/openobject-addons/6.0-opw-574271-skh
Reviewer Review Type Date Requested Status
Naresh(OpenERP) (community) Approve
Review via email: mp+104235@code.launchpad.net

Description of the change

Hello Sir,

{fix]: When we merge 2 Purchase order from the same Supplier, It merges the PO line but did not consider the price-list defined on the product form.
Scenario:
1. Create a "test product" and go-to Supplier tab.
2. Select a Supplier "Test Supplier" and define the price line eg: Qty =0-9 have price =100, Qty = 10-19 has price =90 and Qty = 20 and above has price =80.
3. Now create 2 PO with qty 10 in each(product price = 90), for same supplier as "Test Supplier" and merge the PO.
4. New created PO has qty=20 but the price is 90 where it should be 80.

This branch fixes the issue.

Thanks,
Somesh Khare

To post a comment you must log in.
Revision history for this message
Naresh(OpenERP) (nch-openerp) :
review: Approve

Unmerged revisions

5217. By Somesh Khare

[FIX] Purchase: Mergin of purchase order did not consider the Supplier Pricelist on the product form(Case: ref 574271)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'purchase/purchase.py'
2--- purchase/purchase.py 2012-03-20 10:37:52 +0000
3+++ purchase/purchase.py 2012-05-01 11:17:22 +0000
4@@ -574,22 +574,25 @@
5 order_infos['origin'] = (order_infos['origin'] or '') + ' ' + porder.origin
6
7 for order_line in porder.order_line:
8- line_key = make_key(order_line, ('name', 'date_planned', 'taxes_id', 'price_unit', 'notes', 'product_id', 'move_dest_id', 'account_analytic_id'))
9+ line_key = make_key(order_line, ('name', 'date_planned', 'taxes_id', 'notes', 'product_id', 'move_dest_id', 'account_analytic_id'))
10 o_line = order_infos['order_line'].setdefault(line_key, {})
11 if o_line:
12 # merge the line with an existing line
13 o_line['product_qty'] += order_line.product_qty * order_line.product_uom.factor / o_line['uom_factor']
14+ o_line['price_unit'] = self.pool.get('product.pricelist').price_get(cr,uid,[order_infos['pricelist_id']],
15+ order_line.product_id.id, o_line['product_qty'] or 1.0, order_infos['partner_id'], {
16+ 'uom': o_line['product_uom'],
17+ 'date': time.strftime('%Y-%m-%d'),
18+ })[order_infos['pricelist_id']]
19 else:
20 # append a new "standalone" line
21- for field in ('product_qty', 'product_uom'):
22+ for field in ('product_qty', 'product_uom','price_unit'):
23 field_val = getattr(order_line, field)
24 if isinstance(field_val, browse_record):
25 field_val = field_val.id
26 o_line[field] = field_val
27 o_line['uom_factor'] = order_line.product_uom and order_line.product_uom.factor or 1.0
28
29-
30-
31 allorders = []
32 orders_info = {}
33 for order_key, (order_data, old_ids) in new_orders.iteritems():
34@@ -597,13 +600,12 @@
35 if len(old_ids) < 2:
36 allorders += (old_ids or [])
37 continue
38-
39+
40 # cleanup order line data
41 for key, value in order_data['order_line'].iteritems():
42 del value['uom_factor']
43 value.update(dict(key))
44 order_data['order_line'] = [(0, 0, value) for value in order_data['order_line'].itervalues()]
45-
46 # create the new order
47 neworder_id = self.create(cr, uid, order_data)
48 orders_info.update({neworder_id: old_ids})