Merge lp:~openerp-dev/openobject-addons/trunk-bug-868650-tpa into lp:openobject-addons

Proposed by Turkesh Patel (openERP)
Status: Rejected
Rejected by: Harry (OpenERP)
Proposed branch: lp:~openerp-dev/openobject-addons/trunk-bug-868650-tpa
Merge into: lp:openobject-addons
Diff against target: 67 lines (+25/-21)
1 file modified
mrp/wizard/change_production_qty.py (+25/-21)
To merge this branch: bzr merge lp:~openerp-dev/openobject-addons/trunk-bug-868650-tpa
Reviewer Review Type Date Requested Status
OpenERP Core Team Pending
Review via email: mp+113176@code.launchpad.net

Description of the change

[FIX] MRP:internal moves not updated upon changed production quantity.

To post a comment you must log in.
Revision history for this message
Harry (OpenERP) (hmo-tinyerp) wrote :

it's duplicate bug.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'mrp/wizard/change_production_qty.py'
2--- mrp/wizard/change_production_qty.py 2012-04-25 08:54:15 +0000
3+++ mrp/wizard/change_production_qty.py 2012-07-03 09:07:29 +0000
4@@ -54,6 +54,29 @@
5 for m in prod.move_created_ids:
6 move_lines_obj.write(cr, uid, [m.id], {'product_qty': qty})
7
8+ def _update_product_in_move(self, cr, uid, prod, moves, context=None):
9+ prod_obj = self.pool.get('mrp.production')
10+ bom_obj = self.pool.get('mrp.bom')
11+ move_lines_obj = self.pool.get('stock.move')
12+ for move in moves:
13+ bom_point = prod.bom_id
14+ bom_id = prod.bom_id.id
15+ if not bom_point:
16+ bom_id = bom_obj._bom_find(cr, uid, prod.product_id.id, prod.product_uom.id)
17+ if not bom_id:
18+ raise osv.except_osv(_('Error'), _("Couldn't find bill of material for product"))
19+ prod_obj.write(cr, uid, [prod.id], {'bom_id': bom_id})
20+ bom_point = bom_obj.browse(cr, uid, [bom_id])[0]
21+
22+ if not bom_id:
23+ raise osv.except_osv(_('Error'), _("Couldn't find bill of material for product"))
24+
25+ factor = prod.product_qty * prod.product_uom.factor / bom_point.product_uom.factor
26+ res = bom_obj._bom_explode(cr, uid, bom_point, factor / bom_point.product_qty, [])
27+ for r in res[0]:
28+ if r['product_id'] == move.product_id.id:
29+ move_lines_obj.write(cr, uid, [move.id], {'product_qty' : r['product_qty']})
30+
31 def change_prod_qty(self, cr, uid, ids, context=None):
32 """
33 Changes the Quantity of Product.
34@@ -67,31 +90,12 @@
35 record_id = context and context.get('active_id',False)
36 assert record_id, _('Active Id is not found')
37 prod_obj = self.pool.get('mrp.production')
38- bom_obj = self.pool.get('mrp.bom')
39 for wiz_qty in self.browse(cr, uid, ids, context=context):
40 prod = prod_obj.browse(cr, uid, record_id, context=context)
41 prod_obj.write(cr, uid, [prod.id], {'product_qty': wiz_qty.product_qty})
42 prod_obj.action_compute(cr, uid, [prod.id])
43-
44- move_lines_obj = self.pool.get('stock.move')
45- for move in prod.move_lines:
46- bom_point = prod.bom_id
47- bom_id = prod.bom_id.id
48- if not bom_point:
49- bom_id = bom_obj._bom_find(cr, uid, prod.product_id.id, prod.product_uom.id)
50- if not bom_id:
51- raise osv.except_osv(_('Error'), _("Couldn't find bill of material for product"))
52- prod_obj.write(cr, uid, [prod.id], {'bom_id': bom_id})
53- bom_point = bom_obj.browse(cr, uid, [bom_id])[0]
54-
55- if not bom_id:
56- raise osv.except_osv(_('Error'), _("Couldn't find bill of material for product"))
57-
58- factor = prod.product_qty * prod.product_uom.factor / bom_point.product_uom.factor
59- res = bom_obj._bom_explode(cr, uid, bom_point, factor / bom_point.product_qty, [])
60- for r in res[0]:
61- if r['product_id'] == move.product_id.id:
62- move_lines_obj.write(cr, uid, [move.id], {'product_qty' : r['product_qty']})
63+ self._update_product_in_move(cr, uid, prod, prod.move_lines, context=context)
64+ self._update_product_in_move(cr, uid, prod, prod.picking_id.move_lines, context=context)
65 self._update_product_to_produce(cr, uid, prod, wiz_qty.product_qty, context=context)
66
67 return {}

Subscribers

People subscribed via source and target branches

to all changes: