← Back to team overview

openerp-dev-web team mailing list archive

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

 

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

Requested reviews:
  qdp (OpenERP) (qdp)
Related bugs:
  Bug #739181 in OpenERP Addons: "scrapping in stock moves doesn't require production lot"
  https://bugs.launchpad.net/openobject-addons/+bug/739181

For more details, see:
https://code.launchpad.net/~openerp-dev/openobject-addons/trunk-bug-739181-rpa/+merge/54812

Fixed scrapping move with production lot
-- 
https://code.launchpad.net/~openerp-dev/openobject-addons/trunk-bug-739181-rpa/+merge/54812
Your team OpenERP R&D Team is subscribed to branch lp:~openerp-dev/openobject-addons/trunk-bug-739181-rpa.
=== modified file 'mrp/stock.py'
--- mrp/stock.py	2011-03-01 10:10:41 +0000
+++ mrp/stock.py	2011-03-25 04:59:24 +0000
@@ -137,7 +137,6 @@
         wf_service = netsvc.LocalService("workflow")
         for move in self.browse(cr, uid, ids, context=context):
             new_moves = super(StockMove, self).action_scrap(cr, uid, [move.id], product_qty, location_id, context=context)
-            self.write(cr, uid, [move.id], {'prodlot_id': False, 'tracking_id': False})
             production_ids = production_obj.search(cr, uid, [('move_lines', 'in', [move.id])])
             for prod_id in production_ids:
                 wf_service.trg_validate(uid, 'mrp.production', prod_id, 'button_produce', cr)

=== modified file 'stock/stock.py'
--- stock/stock.py	2011-03-24 13:50:17 +0000
+++ stock/stock.py	2011-03-25 04:59:24 +0000
@@ -2236,6 +2236,7 @@
         if quantity <= 0:
             raise osv.except_osv(_('Warning!'), _('Please provide a positive quantity to scrap!'))
         res = []
+        to_done = []
         for move in self.browse(cr, uid, ids, context=context):
             move_qty = move.product_qty
             uos_qty = quantity / move_qty * move.product_uos_qty
@@ -2251,13 +2252,32 @@
             if move.location_id.usage <> 'internal':
                 default_val.update({'location_id': move.location_dest_id.id})
             new_move = self.copy(cr, uid, move.id, default_val)
-
-            res += [new_move]
+            res.append(new_move)
+            to_done.append(new_move)
+
+            if move.prodlot_id:
+                # Create a new move with the qty of scrapped move without prodlot
+                default_val = {
+                        'product_qty': quantity,
+                        'product_uos_qty': uos_qty,
+                        'tracking_id': move.tracking_id.id,
+                        'prodlot_id': False
+                    }
+                newmove = self.copy(cr, uid, move.id, default_val)
+                res.append(new_move)
+                # Reduce amount of original move by qty of scrapped move
+                if move.product_qty - quantity > 0:
+                    move.write({
+                        'product_qty': move.product_qty - quantity,
+                        'product_uos_qty': move.product_uos_qty - uos_qty,
+                        })
+
+
             product_obj = self.pool.get('product.product')
             for (id, name) in product_obj.name_get(cr, uid, [move.product_id.id]):
                 self.log(cr, uid, move.id, "%s x %s %s" % (move.product_qty, name, _("were scrapped")))
 
-        self.action_done(cr, uid, res)
+        self.action_done(cr, uid, to_done, context=context)
         return res
 
     def action_split(self, cr, uid, ids, quantity, split_by_qty=1, prefix=False, with_lot=True, context=None):

=== modified file 'stock/wizard/stock_move.py'
--- stock/wizard/stock_move.py	2011-03-15 15:03:48 +0000
+++ stock/wizard/stock_move.py	2011-03-25 04:59:24 +0000
@@ -161,9 +161,9 @@
             context = {}
         move_obj = self.pool.get('stock.move')
         move_ids = context['active_ids']
-        for data in self.read(cr, uid, ids):
+        for data in self.browse(cr, uid, ids):
             move_obj.action_scrap(cr, uid, move_ids,
-                             data['product_qty'], data['location_id'],
+                             data.product_qty, data.location_id.id,
                              context=context)
         return {'type': 'ir.actions.act_window_close'}
 


Follow ups