From 42742a440d5425c5da7945688de668787c78f902 Mon Sep 17 00:00:00 2001 From: Numerigraphe - Lionel Sausin Date: Thu, 8 Mar 2012 09:31:39 +0100 Subject: [PATCH 1/2] [REF] clearer variable names bzr revid: ls@numerigraphe.fr-20120308083139-hv80tnovazjrps14 --- addons/procurement/procurement.py | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/addons/procurement/procurement.py b/addons/procurement/procurement.py index 164314c4573..7dca3a8a9e4 100644 --- a/addons/procurement/procurement.py +++ b/addons/procurement/procurement.py @@ -409,23 +409,24 @@ class procurement_order(osv.osv): return 0 def action_cancel(self, cr, uid, ids): - """ Cancels procurement and writes move state to Assigned. + """Cancel Procurements and either cancel or assign the related Stock Moves, depending on the procurement configuration. + @return: True """ - todo = [] - todo2 = [] + to_assign = [] + to_cancel = [] move_obj = self.pool.get('stock.move') for proc in self.browse(cr, uid, ids): if proc.close_move and proc.move_id: if proc.move_id.state not in ('done', 'cancel'): - todo2.append(proc.move_id.id) + to_cancel.append(proc.move_id.id) else: if proc.move_id and proc.move_id.state == 'waiting': - todo.append(proc.move_id.id) - if len(todo2): - move_obj.action_cancel(cr, uid, todo2) - if len(todo): - move_obj.write(cr, uid, todo, {'state': 'assigned'}) + to_assign.append(proc.move_id.id) + if len(to_cancel): + move_obj.action_cancel(cr, uid, to_cancel) + if len(to_assign): + move_obj.write(cr, uid, to_assign, {'state': 'assigned'}) self.write(cr, uid, ids, {'state': 'cancel'}) wf_service = netsvc.LocalService("workflow") for id in ids: From 65dbf53f5505fb18321d3412b19b15eb41008c52 Mon Sep 17 00:00:00 2001 From: Numerigraphe - Lionel Sausin Date: Thu, 8 Mar 2012 09:58:29 +0100 Subject: [PATCH 2/2] [REF] Add an XXX comment about context bzr revid: ls@numerigraphe.fr-20120308085829-7r1pjipa986xsyz6 --- addons/procurement/procurement.py | 1 + 1 file changed, 1 insertion(+) diff --git a/addons/procurement/procurement.py b/addons/procurement/procurement.py index 7dca3a8a9e4..83437cc3657 100644 --- a/addons/procurement/procurement.py +++ b/addons/procurement/procurement.py @@ -408,6 +408,7 @@ class procurement_order(osv.osv): """ return 0 + # XXX action_cancel() should accept a context argument def action_cancel(self, cr, uid, ids): """Cancel Procurements and either cancel or assign the related Stock Moves, depending on the procurement configuration.