Xavier ALT (OpenERP) has proposed merging 
lp:~openerp-dev/openobject-addons/6.1-opw-381582-xal into 
lp:openobject-addons/6.1.

Requested reviews:
  Naresh(OpenERP) (nch-openerp)
Related bugs:
  Bug #915568 in OpenERP Addons: "[6.0] Stock inventory not take DATE to 
calucate stock-move qty."
  https://bugs.launchpad.net/openobject-addons/+bug/915568

For more details, see:
https://code.launchpad.net/~openerp-dev/openobject-addons/6.1-opw-381582-xal/+merge/104061

Hi,

This fix inventory which should force stock inventory move at "inventory date" 
- not today. BTW this also fix duplication of "Inventory" (date should also not 
be copied uppon duplication).

Regards,
Xavier
-- 
https://code.launchpad.net/~openerp-dev/openobject-addons/6.1-opw-381582-xal/+merge/104061
Your team OpenERP R&D Team is subscribed to branch 
lp:~openerp-dev/openobject-addons/6.1-opw-381582-xal.
=== modified file 'stock/stock.py'
--- stock/stock.py	2012-03-29 15:29:29 +0000
+++ stock/stock.py	2012-04-30 07:07:55 +0000
@@ -2631,12 +2631,14 @@
         'company_id': lambda self,cr,uid,c: self.pool.get('res.company')._company_default_get(cr, uid, 'stock.inventory', context=c)
     }
 
-    def copy(self, cr, uid, id, default=None, context=None):
+    def copy_data(self, cr, uid, id, default=None, context=None):
         if default is None:
             default = {}
-        default = default.copy()
-        default.update({'move_ids': [], 'date_done': False})
-        return super(stock_inventory, self).copy(cr, uid, id, default, context=context)
+        # force new date, date_done and move_ids on copied datas
+        default.update(date=False, date_done=False, move_ids=[])
+        copied_data = super(stock_inventory, self).copy_data(cr, uid, id, default=default, context=context)
+        copied_data.pop('date',None)
+        return copied_data
 
     def _inventory_line_hook(self, cr, uid, inventory_line, move_vals):
         """ Creates a stock move from an inventory line
@@ -2654,7 +2656,11 @@
             context = {}
         move_obj = self.pool.get('stock.move')
         for inv in self.browse(cr, uid, ids, context=context):
-            move_obj.action_done(cr, uid, [x.id for x in inv.move_ids], context=context)
+            inventory_move_ids = [x.id for x in inv.move_ids]
+            move_obj.action_done(cr, uid, inventory_move_ids, context=context)
+            # ask 'stock.move' action done are going to change to 'date' of the move,
+            # we overwrite the date as moves must appear at the inventory date.
+            move_obj.write(cr, uid, inventory_move_ids, {'date': inv.date}, context=context)
             self.write(cr, uid, [inv.id], {'state':'done', 'date_done': time.strftime('%Y-%m-%d %H:%M:%S')}, context=context)
         return True
 

_______________________________________________
Mailing list: https://launchpad.net/~openerp-dev-gtk
Post to     : [email protected]
Unsubscribe : https://launchpad.net/~openerp-dev-gtk
More help   : https://help.launchpad.net/ListHelp

Reply via email to