[WIP] Add link with sale order by duplicating. That way sale order will be delivered...
authorJosse Colpaert <jco@odoo.com>
Thu, 14 Aug 2014 14:12:59 +0000 (16:12 +0200)
committerJosse Colpaert <jco@odoo.com>
Wed, 3 Sep 2014 17:18:16 +0000 (19:18 +0200)
addons/mrp/stock.py
addons/sale_service/models/sale_service.py

index 8b77588..f1f98fa 100644 (file)
@@ -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]
 
index d622f07..1ed7463 100644 (file)
@@ -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):