Merge lp:~numerigraphe-team/openobject-addons/6.0-inventory-move-date into lp:openobject-addons/6.0

Proposed by Lionel Sausin - Initiatives/Numérigraphe
Status: Needs review
Proposed branch: lp:~numerigraphe-team/openobject-addons/6.0-inventory-move-date
Merge into: lp:openobject-addons/6.0
Diff against target: 64 lines (+17/-3)
2 files modified
stock/stock.py (+9/-1)
stock/test/stock_test.yml (+8/-2)
To merge this branch: bzr merge lp:~numerigraphe-team/openobject-addons/6.0-inventory-move-date
Reviewer Review Type Date Requested Status
Loïc Bellier - Numérigraphe (community) code review Approve
OpenERP Core Team Pending
Review via email: mp+213303@code.launchpad.net

Description of the change

This branch fixes the date of stock moves for inventory adjustments.
It uses the inventory's date instead of "today", which makes it consistent with the way the starting quantity is already computed.

Entering moves this way was debated at length and judged the right thing to do for v8, and is implemented in trunk-wms.

This branch runs green on runbot: http://runbot.openerp.com/numerigraphe-team-6-0-inventory-move-date-32072/logs/

To post a comment you must log in.
Revision history for this message
Loïc Bellier - Numérigraphe (lb-b) :
review: Approve (code review)

Unmerged revisions

5479. By Numérigraphe

[IMP] Test the date of the inventory stock moves

5478. By Numérigraphe

[FIX] write inventory stock moves at the right 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-08-17 07:46:56 +0000
3+++ stock/stock.py 2014-03-28 16:52:55 +0000
4@@ -2164,7 +2164,11 @@
5 if todo:
6 self.action_confirm(cr, uid, todo, context=context)
7
8- self.write(cr, uid, move_ids, {'state': 'done', 'date': time.strftime('%Y-%m-%d %H:%M:%S')}, context=context)
9+ # Mark the move done, either now or at the datetime required by the context (ie. inventory being done)
10+ self.write(cr, uid, move_ids,
11+ {'state': 'done',
12+ 'date': context.get('move_date', time.strftime('%Y-%m-%d %H:%M:%S'))},
13+ context=context)
14 for id in move_ids:
15 wf_service.trg_trigger(uid, 'stock.move', id, cr)
16
17@@ -2562,8 +2566,11 @@
18 """
19 if context is None:
20 context = {}
21+ else:
22+ context=context.copy()
23 move_obj = self.pool.get('stock.move')
24 for inv in self.browse(cr, uid, ids, context=context):
25+ context['move_date'] = inv.date
26 move_obj.action_done(cr, uid, [x.id for x in inv.move_ids], context=context)
27 self.write(cr, uid, [inv.id], {'state':'done', 'date_done': time.strftime('%Y-%m-%d %H:%M:%S')}, context=context)
28 return True
29@@ -2596,6 +2603,7 @@
30 'product_uom': line.product_uom.id,
31 'prodlot_id': lot_id,
32 'date': inv.date,
33+ 'date_expected': inv.date,
34 }
35 if change > 0:
36 value.update( {
37
38=== modified file 'stock/test/stock_test.yml'
39--- stock/test/stock_test.yml 2012-10-23 11:19:09 +0000
40+++ stock/test/stock_test.yml 2014-03-28 16:52:55 +0000
41@@ -226,8 +226,7 @@
42 -
43 !record {model: stock.inventory, id: stock_inventory_physicalinventoy0}:
44 company_id: base.main_company
45- date: !eval time.strftime('%Y-%m-%d %H:%M:%S')
46- date_done: !eval time.strftime('%Y-%m-%d %H:%M:%S')
47+ date: '2001-01-01 00:00:00'
48 inventory_line_id:
49 - company_id: base.main_company
50 location_id: stock.stock_location_stock
51@@ -250,6 +249,13 @@
52 self.action_confirm(cr,uid,[ref('stock_inventory_physicalinventoy0')])
53 self.action_done(cr,uid,[ref('stock_inventory_physicalinventoy0')])
54 -
55+ I check that stock moves were created for this inventory, and that their date is right
56+-
57+ !python {model: stock.inventory}: |
58+ inventories = self.browse(cr, uid, [ref('stock_inventory_physicalinventoy0')])
59+ assert inventories[0].move_ids, "No stock moves were created during the initial inventory."
60+ assert inventories[0].move_ids[0].date == '2001-01-01 00:00:00', "The stock moves created during the initial inventory have the wrong date."
61+-
62 I create stock.fill.inventory .
63 -
64 !record {model: stock.fill.inventory, id: stock_fill_inventory_0}: