From f630a3a64aa02df339bf4bf856f01357f5086f77 Mon Sep 17 00:00:00 2001 From: Paramjit Singh Sahota Date: Mon, 27 May 2013 16:39:01 +0530 Subject: [PATCH] [IMP] Added context whereever necessary, improved code of action_done and removed unwanted spaces. bzr revid: psa@tinyerp.com-20130527110901-q6717focg99qq46a --- addons/mrp/mrp.py | 6 +++--- addons/mrp/mrp_workflow.xml | 3 +-- addons/mrp/stock.py | 12 +++++------- 3 files changed, 9 insertions(+), 12 deletions(-) diff --git a/addons/mrp/mrp.py b/addons/mrp/mrp.py index 0d210544356..ef31f7aaa87 100644 --- a/addons/mrp/mrp.py +++ b/addons/mrp/mrp.py @@ -776,7 +776,7 @@ class mrp_production(osv.osv): new_parent_ids.append(final_product.id) for new_parent_id in new_parent_ids: stock_mov_obj.write(cr, uid, [raw_product.id], {'move_history_ids': [(4,new_parent_id)]}) - + wf_service = netsvc.LocalService("workflow") wf_service.trg_validate(uid, 'mrp.production', production_id, 'button_produce_done', cr) return True @@ -985,7 +985,7 @@ class mrp_production(osv.osv): for production in self.browse(cr, uid, ids, context=context): shipment_id = self._make_production_internal_shipment(cr, uid, production, context=context) produce_move_id = self._make_production_produce_line(cr, uid, production, context=context) - + # Take routing location as a Source Location. source_location_id = production.location_src_id.id if production.bom_id.routing_id and production.bom_id.routing_id.location_id: @@ -996,7 +996,7 @@ class mrp_production(osv.osv): shipment_move_id = self._make_production_internal_shipment_line(cr, uid, line, shipment_id, consume_move_id,\ destination_location_id=source_location_id, context=context) self._make_production_line_procurement(cr, uid, line, shipment_move_id, context=context) - + wf_service.trg_validate(uid, 'stock.picking', shipment_id, 'button_confirm', cr) production.write({'state':'confirmed'}, context=context) return shipment_id diff --git a/addons/mrp/mrp_workflow.xml b/addons/mrp/mrp_workflow.xml index b57fe64158e..93dacc15f3c 100644 --- a/addons/mrp/mrp_workflow.xml +++ b/addons/mrp/mrp_workflow.xml @@ -73,7 +73,7 @@ picking_id and picking_id.state=='done' - + button_produce_done @@ -85,7 +85,6 @@ button_produce - diff --git a/addons/mrp/stock.py b/addons/mrp/stock.py index 1404f2bbcb0..789ca876242 100644 --- a/addons/mrp/stock.py +++ b/addons/mrp/stock.py @@ -153,14 +153,12 @@ class StockMove(osv.osv): production_obj = self.pool.get('mrp.production') wf_service = netsvc.LocalService("workflow") for move in self.browse(cr, uid, ids, context=context): - production_ids = production_obj.search(cr, uid, [('move_created_ids', 'in', [move.id])]) + production_ids = production_obj.search(cr, uid, [('move_created_ids', 'in', [move.id])], context=context) if production_ids: - product_data = production_obj.browse(cr, uid, production_ids[0]) - if product_data.move_created_ids2 and product_data.move_lines2 and move.state=='done': + product_data = production_obj.browse(cr, uid, production_ids[0], context=context) + if product_data.move_created_ids2 and move.state=='done': wf_service.trg_validate(uid, 'mrp.production', product_data.id, 'button_produce_done', cr) - elif not product_data.move_lines2 and move.state=='done': - wf_service.trg_validate(uid, 'mrp.production', product_data.id, 'button_produce_done', cr) - return res + return res StockMove() @@ -184,7 +182,7 @@ class StockPicking(osv.osv): for pick in self.browse(cr, uid, ids, context=context): if not pick.move_lines: return False - return res + return res StockPicking()