Merge lp:~openerp-dev/openobject-addons/6.0-opw-381582-xal into lp:openobject-addons/6.0

Proposed by Xavier ALT
Status: Approved
Approved by: Naresh(OpenERP)
Approved revision: 5174
Proposed branch: lp:~openerp-dev/openobject-addons/6.0-opw-381582-xal
Merge into: lp:openobject-addons/6.0
Diff against target: 31 lines (+14/-1)
1 file modified
stock/stock.py (+14/-1)
To merge this branch: bzr merge lp:~openerp-dev/openobject-addons/6.0-opw-381582-xal
Reviewer Review Type Date Requested Status
Numérigraphe (community) Needs Fixing
Naresh(OpenERP) (community) Approve
Review via email: mp+104060@code.launchpad.net

Description of the change

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

To post a comment you must log in.
Revision history for this message
Naresh(OpenERP) (nch-openerp) :
review: Approve
Revision history for this message
Numérigraphe (numerigraphe) wrote :

This should fix the problem indeed.
Why has it not been merged yet?

On a side note, an automatic test would be welcome here.

Lionel.

review: Approve
Revision history for this message
Numérigraphe (numerigraphe) wrote :

Sorry to change my mind again, but I think this patch is needed too : https://launchpadlibrarian.net/91025725/stock_inventory_date.patch
Patch provided by Xavier Fernandez in the bug report (comment #4).

review: Needs Fixing
Revision history for this message
Numérigraphe (numerigraphe) wrote :

This can be refined by setting the "expected date" to the date of the inventory when it is confirmed and not yet validated.
This will make the virtual stock correct at that date.
Lionel.

review: Needs Fixing
Revision history for this message
Numérigraphe (numerigraphe) wrote :

Also, this conflicts with [1] which introduces a copy() method.
Lionel.
[1] https://code.launchpad.net/~openerp-dev/openobject-addons/6.0-opw-575823-ado/+merge/110044

review: Needs Fixing

Unmerged revisions

5174. By Xavier ALT

[FIX] stock: on 'inventory' validation, force stock move date at inventory date

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== 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 @@
2548 'company_id': lambda self,cr,uid,c: self.pool.get('res.company')._company_default_get(cr, uid, 'stock.inventory', context=c)2548 'company_id': lambda self,cr,uid,c: self.pool.get('res.company')._company_default_get(cr, uid, 'stock.inventory', context=c)
2549 }2549 }
25502550
2551 def copy_data(self, cr, uid, id, default=None, context=None):
2552 if default is None:
2553 default = {}
2554 # force new date, date_done and move_ids on copied datas
2555 default.update(date=False, date_done=False, move_ids=[])
2556 copied_data = super(stock_inventory, self).copy_data(cr, uid, id, default=default, context=context)
2557 copied_data.pop('date',None)
2558 return copied_data
2559
2551 def _inventory_line_hook(self, cr, uid, inventory_line, move_vals):2560 def _inventory_line_hook(self, cr, uid, inventory_line, move_vals):
2552 """ Creates a stock move from an inventory line2561 """ Creates a stock move from an inventory line
2553 @param inventory_line:2562 @param inventory_line:
@@ -2564,7 +2573,11 @@
2564 context = {}2573 context = {}
2565 move_obj = self.pool.get('stock.move')2574 move_obj = self.pool.get('stock.move')
2566 for inv in self.browse(cr, uid, ids, context=context):2575 for inv in self.browse(cr, uid, ids, context=context):
2567 move_obj.action_done(cr, uid, [x.id for x in inv.move_ids], context=context)2576 inventory_move_ids = [x.id for x in inv.move_ids]
2577 move_obj.action_done(cr, uid, inventory_move_ids, context=context)
2578 # ask 'stock.move' action done are going to change to 'date' of the move,
2579 # we overwrite the date as moves must appear at the inventory date.
2580 move_obj.write(cr, uid, inventory_move_ids, {'date': inv.date}, context=context)
2568 self.write(cr, uid, [inv.id], {'state':'done', 'date_done': time.strftime('%Y-%m-%d %H:%M:%S')}, context=context)2581 self.write(cr, uid, [inv.id], {'state':'done', 'date_done': time.strftime('%Y-%m-%d %H:%M:%S')}, context=context)
2569 return True2582 return True
25702583