Merge lp:~numerigraphe/openobject-addons/trunk-extra-sale_picking_reservation-procurements into lp:openobject-addons/extra-trunk

Proposed by Numérigraphe
Status: Needs review
Proposed branch: lp:~numerigraphe/openobject-addons/trunk-extra-sale_picking_reservation-procurements
Merge into: lp:openobject-addons/extra-trunk
Diff against target: 77 lines (+25/-5)
3 files modified
sale_picking_reservation/__openerp__.py (+1/-1)
sale_picking_reservation/sale.py (+16/-3)
sale_picking_reservation/stock_workflow.xml (+8/-1)
To merge this branch: bzr merge lp:~numerigraphe/openobject-addons/trunk-extra-sale_picking_reservation-procurements
Reviewer Review Type Date Requested Status
OpenERP Committers Pending
Sébastien BEAU - http://www.akretion.com original committer Pending
Review via email: mp+96196@code.launchpad.net

Description of the change

This branch changes sale_picking_reservation so that canceling reservations also cancels the associated procurements.
Otherwise, goods will be purchased or manufactured for nothing.

You can't delete the pickings and cancel the procurements, so I propose to cancel the pickings instead of deleting them.
To this end I added a missing transition to the picking workflow.
Canceling the picking raises exceptions in procurements, which can then be canceled.
Lionel Sausin.

To post a comment you must log in.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'sale_picking_reservation/__openerp__.py'
2--- sale_picking_reservation/__openerp__.py 2012-03-06 16:29:20 +0000
3+++ sale_picking_reservation/__openerp__.py 2012-03-06 17:50:26 +0000
4@@ -22,7 +22,7 @@
5
6 {
7 'name': 'sale_picking_reservation',
8- 'version': '0.1',
9+ 'version': '0.2',
10 'category': 'Generic Modules',
11 'license': 'AGPL-3',
12 'description': """This module add the possibility to reserve the product of the quotation line before validating the sale order.""",
13
14=== modified file 'sale_picking_reservation/sale.py'
15--- sale_picking_reservation/sale.py 2012-03-06 16:29:20 +0000
16+++ sale_picking_reservation/sale.py 2012-03-06 17:50:26 +0000
17@@ -54,17 +54,30 @@
18
19 def action_reserve(self, cr, uid, ids, *args):
20 """Reserve the goods"""
21+ self.action_ship_create(cr, uid, ids, {'reserved': True})
22 self.write(cr, uid, ids, {'reserved': True})
23- self.action_ship_create(cr, uid, ids, {'reserved': True})
24 return True
25
26 def action_unreserve(self, cr, uid, ids, *args):
27 """Cancel the reservation"""
28+ wf_service = netsvc.LocalService("workflow")
29 self.write(cr, uid, ids, {'reserved': False})
30 for sale in self.browse(cr, uid, ids):
31- # FIXME procurements should be canceled first!
32+ # Cancel the picking (deleting it would not cancel the procurements!)
33 for picking in sale.picking_ids:
34- picking.unlink()
35+ wf_service.trg_validate(uid, 'stock.picking', picking.id,
36+ 'button_cancel', cr)
37+ # Cancel the procurements
38+ for move in sale.order_line:
39+ if move.procurement_id:
40+ # Check that canceling the picking raised procurement exceptions
41+ wf_service.trg_validate(uid, 'procurement.order',
42+ move.procurement_id.id,
43+ 'button_check', cr)
44+ # Cancel the procurement
45+ wf_service.trg_validate(uid, 'procurement.order',
46+ move.procurement_id.id,
47+ 'button_cancel', cr)
48 return True
49
50 def action_ship_create(self, cr, uid, ids, *args):
51
52=== modified file 'sale_picking_reservation/stock_workflow.xml'
53--- sale_picking_reservation/stock_workflow.xml 2011-11-14 14:57:34 +0000
54+++ sale_picking_reservation/stock_workflow.xml 2012-03-06 17:50:26 +0000
55@@ -2,7 +2,7 @@
56 <!--
57 sale_picking_reservation for OpenERP
58 Copyright (C) 2011 Akretion Sébastien BEAU <sebastien.beau@akretion.com>
59- The licence is in the file __terp__.py
60+ The licence is in the file __openerp__.py
61 -->
62 <openerp>
63 <data>
64@@ -32,6 +32,13 @@
65 <field name="act_to" ref="stock.act_confirmed"/>
66 <field name="signal">button_confirm_reserved</field>
67 </record>
68+
69+ <record id="trans_reserved_picking_cancel" model="workflow.transition">
70+ <field name="act_from" ref="act_picking_reserved"/>
71+ <field name="act_to" ref="stock.act_cancel"/>
72+ <field name="condition">allow_cancel()</field>
73+ <field name="signal">button_cancel</field>
74+ </record>
75
76 </data>
77 </openerp>

Subscribers

People subscribed via source and target branches