← Back to team overview

openerp-dev-web team mailing list archive

[Merge] lp:~openerp-dev/openobject-addons/rpa-dev-addons2 into lp:~openerp-dev/openobject-addons/trunk-dev-addons2

 

rpa (Open ERP) has proposed merging lp:~openerp-dev/openobject-addons/rpa-dev-addons2 into lp:~openerp-dev/openobject-addons/trunk-dev-addons2.

Requested reviews:
  OpenERP Core Team (openerp)
Related bugs:
  #511193 unit factor is limited to 5 zeros
  https://bugs.launchpad.net/bugs/511193
  #535401 Production orders ignore chained location at destination
  https://bugs.launchpad.net/bugs/535401
  #641110 Cannot record outgoing stock move with prodlot for consumable products
  https://bugs.launchpad.net/bugs/641110
  #663662 [6.0rc1] bug in 'request a quotation' from PR
  https://bugs.launchpad.net/bugs/663662
  #663999 [6.0RC1] delivery - usability issues
  https://bugs.launchpad.net/bugs/663999
  #664344 Unclear help texts in product_expiry
  https://bugs.launchpad.net/bugs/664344
  #666781 useless list comprehension and browse in split_moves
  https://bugs.launchpad.net/bugs/666781
  #667327 [v6 RC1] Consume products in Production order not working in GTK client
  https://bugs.launchpad.net/bugs/667327
  #667558 product_visible_discount uses discount in changing UoM in sale order of OpenERP v6.0 rc1
  https://bugs.launchpad.net/bugs/667558
  #683718 [v6 RC1] stock addon: _product_value badly implemented
  https://bugs.launchpad.net/bugs/683718

-- 
https://code.launchpad.net/~openerp-dev/openobject-addons/rpa-dev-addons2/+merge/44454
Your team OpenERP R&D Team is subscribed to branch lp:~openerp-dev/openobject-addons/rpa-dev-addons2.
=== modified file 'mrp/mrp.py'
--- mrp/mrp.py	2010-12-21 06:02:24 +0000
+++ mrp/mrp.py	2010-12-22 12:41:22 +0000
@@ -665,8 +665,6 @@
         stock_mov_obj = self.pool.get('stock.move')
         production = self.browse(cr, uid, production_id, context=context)
 
-        final_product_todo = []
-
         produced_qty = 0
         if production_mode == 'consume_produce':
             produced_qty = production_qty
@@ -706,10 +704,7 @@
                             stock_mov_obj.action_consume(cr, uid, [raw_product.id], consumed_qty, production.location_src_id.id, context=context)
 
         if production_mode == 'consume_produce':
-            # To produce remaining qty of final product
-            vals = {'state':'confirmed'}
-            final_product_todo = [x.id for x in production.move_created_ids]
-            stock_mov_obj.write(cr, uid, final_product_todo, vals)
+
             produced_products = {}
             for produced_product in production.move_created_ids2:
                 if produced_product.scrapped:

=== modified file 'mrp/stock.py'
--- mrp/stock.py	2010-12-16 04:33:35 +0000
+++ mrp/stock.py	2010-12-22 12:41:22 +0000
@@ -140,6 +140,13 @@
                 res.append(new_move)
         return {}
 
+    def trigger_move_state(self, cr, uid, move, state, context=None):
+        new_moves = super(StockMove, self).trigger_move_state(cr, uid, move, state, context=context)
+        if state == 'confirm':
+            new_moves =[x.id for x in new_moves]
+            self.write(cr, uid, new_moves, {'production_id': False}, context=context)
+        return new_moves
+
 StockMove()
 
 

=== modified file 'stock/stock.py'
--- stock/stock.py	2010-12-22 05:48:27 +0000
+++ stock/stock.py	2010-12-22 12:41:22 +0000
@@ -1762,7 +1762,8 @@
                     result.setdefault(m.picking_id, [])
                     result[m.picking_id].append( (m, dest) )
         return result
-    def _create_chained_picking(self, cr, uid, pick_name,picking,ptype,move, context=None):
+
+    def _create_chained_picking(self, cr, uid, pick_name, picking, ptype, move, context=None):
         res_obj = self.pool.get('res.company')
         picking_obj = self.pool.get('stock.picking')
         pick_id= picking_obj.create(cr, uid, {
@@ -1779,6 +1780,7 @@
                                 'date': picking.date,
                             })
         return pick_id
+
     def action_confirm(self, cr, uid, ids, context=None):
         """ Confirms stock move.
         @return: List of ids.
@@ -1794,11 +1796,18 @@
             new_moves = []
             if context is None:
                 context = {}
+            seq_obj = self.pool.get('ir.sequence')
             for picking, todo in self._chain_compute(cr, uid, moves, context=context).items():
                 ptype = todo[0][1][5] and todo[0][1][5] or location_obj.picking_type_get(cr, uid, todo[0][0].location_dest_id, todo[0][1][0])
-                pick_name = picking.name or ''
                 if picking:
-                    pickid = self._create_chained_picking(cr, uid, pick_name,picking,ptype,todo,context)
+                    # name of new picking according to its type
+                    new_pick_name = seq_obj.get(cr, uid, 'stock.picking.' + ptype)
+                    pickid = self._create_chained_picking(cr, uid, new_pick_name, picking, ptype, todo, context=context)
+                    # Need to check name of old picking because it always considers picking as "OUT" when created from Sale Order
+                    old_ptype = location_obj.picking_type_get(cr, uid, picking.move_lines[0].location_id, picking.move_lines[0].location_dest_id)
+                    if old_ptype != picking.type:
+                        old_pick_name = seq_obj.get(cr, uid, 'stock.picking.' + old_ptype)
+                        self.pool.get('stock.picking').write(cr, uid, picking.id, {'name': old_pick_name}, context=context)
                 else:
                     pickid = False
                 for move, (loc, dummy, delay, dummy, company_id, ptype) in todo:
@@ -1821,9 +1830,10 @@
                 if pickid:
                     wf_service.trg_validate(uid, 'stock.picking', pickid, 'button_confirm', cr)
             if new_moves:
-                create_chained_picking(self, cr, uid, new_moves, context)
-        create_chained_picking(self, cr, uid, moves, context)
-        return []
+                new_moves += create_chained_picking(self, cr, uid, new_moves, context)
+            return new_moves
+        all_moves = create_chained_picking(self, cr, uid, moves, context)
+        return all_moves
 
     def action_assign(self, cr, uid, ids, *args):
         """ Changes state to confirmed or waiting.
@@ -2076,10 +2086,9 @@
             if move.picking_id:
                 picking_ids.append(move.picking_id.id)
             if move.move_dest_id.id and (move.state != 'done'):
-                self.write(cr, uid, [move.id], {'move_history_ids': [(4, move.move_dest_id.id)]})
-                #cr.execute('insert into stock_move_history_ids (parent_id,child_id) values (%s,%s)', (move.id, move.move_dest_id.id))
+                self.write(cr, uid, [move.id], {'stock_move_history_ids': [(4, move.move_dest_id.id)]}, context=context)
                 if move.move_dest_id.state in ('waiting', 'confirmed'):
-                    self.write(cr, uid, [move.move_dest_id.id], {'state': 'assigned'})
+                    self.action_assign(cr, uid, [move.move_dest_id.id])
                     if move.move_dest_id.picking_id:
                         wf_service.trg_write(uid, 'stock.picking', move.move_dest_id.picking_id.id, cr)
                     if move.move_dest_id.auto_validate:
@@ -2265,7 +2274,18 @@
                 self.write(cr, uid, [current_move], update_val)
         return res
 
-    def action_consume(self, cr, uid, ids, quantity, location_id=False, context=None):
+    def trigger_move_state(self, cr, uid, move, state, context=None):
+        if isinstance(move, (int, long)):
+            move = [move]
+        res = []
+        if state == 'confirm':
+            res = self.action_confirm(cr, uid, move, context=context)
+        if state == 'assigned':
+            self.check_assign(cr, uid, move, context=context)
+            self.force_assign(cr, uid, move, context=context)
+        return res
+
+    def action_consume(self, cr, uid, ids, quantity, location_id=False,  context=None):
         """ Consumed product with specific quatity from specific source location
         @param cr: the database cursor
         @param uid: the user id
@@ -2293,12 +2313,12 @@
                 quantity = move.product_qty
 
             uos_qty = quantity / move_qty * move.product_uos_qty
+            state = (move.state in ('confirm', 'assign') and move.state) or 'confirm'
 
             if quantity_rest > 0:
                 default_val = {
                     'product_qty': quantity,
                     'product_uos_qty': uos_qty,
-                    'state': move.state,
                     'location_id': location_id or move.location_id.id,
                 }
                 if (not move.prodlot_id.id) and (move.product_id.track_production and location_id):
@@ -2331,6 +2351,8 @@
                 for (id, name) in product_obj.name_get(cr, uid, [new_move.product_id.id]):
                     message = _('Product ') + " '" + name + "' "+ _("is consumed with") + " '" + str(new_move.product_qty) + "' "+ _("quantity.")
                     self.log(cr, uid, new_move.id, message)
+
+            self.trigger_move_state(cr, uid, res, state, context=context)
         self.action_done(cr, uid, res)
 
         return res


Follow ups