Merge lp:~donkirkby/openobject-addons/complete-procurement into lp:openobject-addons/5.0

Proposed by Don Kirkby
Status: Merged
Merged at revision: 2922
Proposed branch: lp:~donkirkby/openobject-addons/complete-procurement
Merge into: lp:openobject-addons/5.0
Diff against target: 164 lines (+135/-2)
3 files modified
mrp/__terp__.py (+1/-1)
mrp/mrp_test.xml (+122/-0)
purchase/purchase.py (+12/-1)
To merge this branch: bzr merge lp:~donkirkby/openobject-addons/complete-procurement
Reviewer Review Type Date Requested Status
Olivier Dony (Odoo) Approve
OpenERP Core Team Pending
Review via email: mp+20694@code.launchpad.net

Description of the change

This now fixes bug lp:532148, as well as adding a unit test that shows the problem.

To post a comment you must log in.
Revision history for this message
Olivier Dony (Odoo) (odo-openerp) wrote :

Excellent, we'll merge this along with the bugfix.

I also propose to start putting the tests into a separate test/ subdirectory in each module, in case we have many of them (and we'll also put the future yaml ones there as well)

Many thanks for helping up with the regression testing!

review: Approve
Revision history for this message
Don Kirkby (donkirkby) wrote :

OK, the branch now contains a fix as well as the unit test. Please review again.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'mrp/__terp__.py'
--- mrp/__terp__.py 2009-02-03 17:02:20 +0000
+++ mrp/__terp__.py 2011-01-06 23:27:08 +0000
@@ -72,7 +72,7 @@
72 'process/service_product_process.xml',72 'process/service_product_process.xml',
73 'process/procurement_process.xml'73 'process/procurement_process.xml'
74 ],74 ],
75 'demo_xml': ['mrp_demo.xml', 'mrp_order_point.xml'],75 'demo_xml': ['mrp_demo.xml', 'mrp_order_point.xml', 'mrp_test.xml'],
76 'installable': True,76 'installable': True,
77 'active': False,77 'active': False,
78 'certificate': '0032052481373',78 'certificate': '0032052481373',
7979
=== added file 'mrp/mrp_test.xml'
--- mrp/mrp_test.xml 1970-01-01 00:00:00 +0000
+++ mrp/mrp_test.xml 2011-01-06 23:27:08 +0000
@@ -0,0 +1,122 @@
1<?xml version="1.0" encoding="UTF-8"?>
2<openerp>
3 <data>
4
5 <!-- ================================================================
6 Smoke test for automated purchase process.
7
8 0. Create a procurement order
9 1. Run the procurement
10 2. Check that the purchase order was created
11 3. Confirm the purchase order
12 4. Receive the goods
13 5. Check that the procurement order was marked as done.
14
15 ================================================================
16 -->
17
18 <!-- ==== 0. Create a procurement order ==== -->
19 <record id="test_procurement_1" model="mrp.procurement">
20 <field name="product_uom" ref="product.product_uom_unit"/>
21 <field eval="3.0" name="product_qty"/>
22 <field name="product_uos" ref="product.product_uom_unit"/>
23 <field name="location_id" ref="stock.stock_location_stock"/>
24 <field eval="0" name="close_move"/>
25 <field name="name">test</field>
26 <field name="procure_method">make_to_order</field>
27 <field name="product_id" ref="product.product_product_mb1"/>
28 </record>
29
30 <!-- ==== 1. Run the procurement ==== -->
31 <workflow
32 model="mrp.procurement"
33 ref="test_procurement_1"
34 action="button_confirm" />
35 <workflow
36 model="mrp.procurement"
37 ref="test_procurement_1"
38 action="button_check" />
39
40 <!-- ==== 2. Check that the purchase order was created ==== -->
41 <assert
42 model="mrp.procurement"
43 id="test_procurement_1"
44 string="Test procurement's purchase order state">
45 <test expr="purchase_id.state">draft</test>
46 </assert>
47 <assert
48 model="mrp.procurement"
49 id="test_procurement_1"
50 string="Test procurement's state">
51 <test expr="state">running</test>
52 </assert>
53
54 <!-- ==== 3. Confirm the purchase order ==== -->
55 <workflow model="purchase.order" action="purchase_confirm" >
56 <value
57 model="mrp.procurement"
58 eval="obj(ref('test_procurement_1')).purchase_id.id"/>
59 </workflow>
60
61 <assert
62 model="mrp.procurement"
63 id="test_procurement_1"
64 string="Test procurement's purchase order state">
65 <test expr="purchase_id.state">confirmed</test>
66 </assert>
67
68 <workflow
69 model="purchase.order"
70 action="purchase_approve"
71 uid="base.user_root" >
72 <value
73 model="mrp.procurement"
74 eval="obj(ref('test_procurement_1')).purchase_id.id"/>
75 </workflow>
76
77 <assert
78 model="mrp.procurement"
79 id="test_procurement_1"
80 string="Test procurement's purchase order state">
81 <test expr="purchase_id.state">approved</test>
82 </assert>
83
84 <!-- ==== 4. Receive the goods ==== -->
85 <!-- Do the same as in wizard_partial_picking lines 143-144
86 (copied from purchase_unit_test.xml) -->
87 <function model="stock.picking" name="action_move">
88 <value
89 model="mrp.procurement"
90 eval="[obj(ref('test_procurement_1')).purchase_id.picking_ids[0].id]"/>
91 </function>
92
93 <workflow model="stock.picking" action="button_done">
94 <value
95 model="mrp.procurement"
96 eval="obj(ref('test_procurement_1')).purchase_id.picking_ids[0].id"/>
97 </workflow>
98
99 <!-- ==== 5. Check that the procurement order was marked as done. ==== -->
100 <assert
101 model="mrp.procurement"
102 id="test_procurement_1"
103 string="Test procurement's purchase order's picking's state">
104 <test expr="purchase_id.picking_ids[0].state">done</test>
105 </assert>
106
107 <assert
108 model="mrp.procurement"
109 id="test_procurement_1"
110 string="Test procurement's purchase order's state">
111 <!-- not done because we didn't process the invoice. -->
112 <test expr="purchase_id.state">approved</test>
113 </assert>
114
115 <assert
116 model="mrp.procurement"
117 id="test_procurement_1"
118 string="Test procurement's state">
119 <test expr="state">done</test>
120 </assert>
121 </data>
122</openerp>
0\ No newline at end of file123\ No newline at end of file
1124
=== modified file 'purchase/purchase.py'
--- purchase/purchase.py 2010-09-03 10:10:26 +0000
+++ purchase/purchase.py 2011-01-06 23:27:08 +0000
@@ -424,7 +424,18 @@
424 'purchase_line_id': order_line.id,424 'purchase_line_id': order_line.id,
425 })425 })
426 if order_line.move_dest_id:426 if order_line.move_dest_id:
427 self.pool.get('stock.move').write(cr, uid, [order_line.move_dest_id.id], {'location_id':order.location_id.id})427 # make the procurement's stock move into a dummy move
428 # (source == destination) and mark it as auto validate
429 # so that the procurement will complete when the
430 # purchase shipment arrives.
431 self.pool.get('stock.move').write(
432 cr,
433 uid,
434 [order_line.move_dest_id.id],
435 {
436 'location_id': order.location_id.id,
437 'auto_validate': True
438 })
428 todo_moves.append(move) 439 todo_moves.append(move)
429 self.pool.get('stock.move').action_confirm(cr, uid, todo_moves)440 self.pool.get('stock.move').action_confirm(cr, uid, todo_moves)
430 self.pool.get('stock.move').force_assign(cr, uid, todo_moves)441 self.pool.get('stock.move').force_assign(cr, uid, todo_moves)