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
1=== modified file 'stock/stock.py'
2--- stock/stock.py 2012-04-25 10:20:20 +0000
3+++ stock/stock.py 2012-04-30 07:04:27 +0000
4@@ -2548,6 +2548,15 @@
5 'company_id': lambda self,cr,uid,c: self.pool.get('res.company')._company_default_get(cr, uid, 'stock.inventory', context=c)
6 }
7
8+ def copy_data(self, cr, uid, id, default=None, context=None):
9+ if default is None:
10+ default = {}
11+ # force new date, date_done and move_ids on copied datas
12+ default.update(date=False, date_done=False, move_ids=[])
13+ copied_data = super(stock_inventory, self).copy_data(cr, uid, id, default=default, context=context)
14+ copied_data.pop('date',None)
15+ return copied_data
16+
17 def _inventory_line_hook(self, cr, uid, inventory_line, move_vals):
18 """ Creates a stock move from an inventory line
19 @param inventory_line:
20@@ -2564,7 +2573,11 @@
21 context = {}
22 move_obj = self.pool.get('stock.move')
23 for inv in self.browse(cr, uid, ids, context=context):
24- move_obj.action_done(cr, uid, [x.id for x in inv.move_ids], context=context)
25+ inventory_move_ids = [x.id for x in inv.move_ids]
26+ move_obj.action_done(cr, uid, inventory_move_ids, context=context)
27+ # ask 'stock.move' action done are going to change to 'date' of the move,
28+ # we overwrite the date as moves must appear at the inventory date.
29+ move_obj.write(cr, uid, inventory_move_ids, {'date': inv.date}, context=context)
30 self.write(cr, uid, [inv.id], {'state':'done', 'date_done': time.strftime('%Y-%m-%d %H:%M:%S')}, context=context)
31 return True
32