From 1a9eb523414b0806f33068881943f4320633a9aa Mon Sep 17 00:00:00 2001 From: Josse Colpaert Date: Thu, 14 Aug 2014 16:12:59 +0200 Subject: [PATCH] [WIP] Add link with sale order by duplicating. That way sale order will be delivered when procurement is done --- addons/mrp/stock.py | 16 +++++++++++----- addons/sale_service/models/sale_service.py | 1 - 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/addons/mrp/stock.py b/addons/mrp/stock.py index 8b77588db10..f1f98faf2f4 100644 --- a/addons/mrp/stock.py +++ b/addons/mrp/stock.py @@ -93,11 +93,11 @@ class StockMove(osv.osv): 'procurement_id': move.procurement_id.id, 'split_from': move.id, #Needed in order to keep purchase connection, but will be removed by unlink } - mid = move_obj.copy(cr, uid, move.id, default=valdef) + mid = move_obj.copy(cr, uid, move.id, default=valdef, context=context) to_explode_again_ids.append(mid) else: if prod_obj.need_procurement(cr, uid, [product.id], context=context): - vals = { + valdef = { 'name': move.rule_id and move.rule_id.name or "/", 'origin': move.origin, 'company_id': move.company_id and move.company_id.id or False, @@ -110,16 +110,22 @@ class StockMove(osv.osv): 'group_id': move.group_id.id, 'priority': move.priority, 'partner_dest_id': move.partner_id.id, + 'move_dest_id': move.id, } - proc = proc_obj.create(cr, uid, vals, context=context) + if move.procurement_id: + proc = proc_obj.copy(cr, uid, move.procurement_id.id, default=valdef, context=context) + else: + proc = proc_obj.create(cr, uid, valdef, context=context) proc_obj.run(cr, uid, [proc], context=context) - #delete the move with original product which is not relevant anymore - move_obj.unlink(cr, SUPERUSER_ID, [move.id], context=context) + #check if new moves needs to be exploded if to_explode_again_ids: for new_move in self.browse(cr, uid, to_explode_again_ids, context=context): processed_ids.extend(self._action_explode(cr, uid, new_move, context=context)) + + #delete the move with original product which is not relevant anymore + move_obj.unlink(cr, SUPERUSER_ID, [move.id], context=context) #return list of newly created move or the move id otherwise return processed_ids or [move.id] diff --git a/addons/sale_service/models/sale_service.py b/addons/sale_service/models/sale_service.py index d622f076cbb..1ed7463db4d 100644 --- a/addons/sale_service/models/sale_service.py +++ b/addons/sale_service/models/sale_service.py @@ -27,7 +27,6 @@ class procurement_order(osv.osv): _inherit = "procurement.order" _columns = { 'task_id': fields.many2one('project.task', 'Task', copy=False), - 'sale_line_id': fields.many2one('sale.order.line', 'Sales order line', copy=False) } def _is_procurement_task(self, cr, uid, procurement, context=None):