Xavier ALT (OpenERP) has proposed merging
lp:~openerp-dev/openobject-addons/6.0-opw-381582-xal into
lp:openobject-addons/6.0.
Requested reviews:
Naresh(OpenERP) (nch-openerp)
For more details, see:
https://code.launchpad.net/~openerp-dev/openobject-addons/6.0-opw-381582-xal/+merge/104060
Hi,
This fix inventory which should force stock inventory move at "inventory date"
- not today. BTW this also fix duplication of "Inventory" (move_ids, date,
date_done should not be copied uppon duplication).
Regards,
Xavier
--
https://code.launchpad.net/~openerp-dev/openobject-addons/6.0-opw-381582-xal/+merge/104060
Your team OpenERP R&D Team is subscribed to branch
lp:~openerp-dev/openobject-addons/6.0-opw-381582-xal.
=== modified file 'stock/stock.py'
--- stock/stock.py 2012-04-25 10:20:20 +0000
+++ stock/stock.py 2012-04-30 07:04:27 +0000
@@ -2548,6 +2548,15 @@
'company_id': lambda self,cr,uid,c: self.pool.get('res.company')._company_default_get(cr, uid, 'stock.inventory', context=c)
}
+ def copy_data(self, cr, uid, id, default=None, context=None):
+ if default is None:
+ default = {}
+ # 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
@param inventory_line:
@@ -2564,7 +2573,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