From a2f9b86b859efc70d9c514022ead46fcda89db04 Mon Sep 17 00:00:00 2001 From: Bertrand Chenal Date: Thu, 8 May 2008 15:54:35 +0200 Subject: [PATCH] Adding wizard around inventory cancellation function. --- inventory.py | 36 +++++++++++++++++++++++++++++++++++- inventory.xml | 20 +++++++++++++++++++- 2 files changed, 54 insertions(+), 2 deletions(-) diff --git a/inventory.py b/inventory.py index 6c6d1aaac7..6eeac32414 100644 --- a/inventory.py +++ b/inventory.py @@ -36,7 +36,6 @@ class Inventory(OSV): self._order.insert(0, ('date', 'DESC')) self._rpc_allowed += [ 'set_state_done', - 'set_state_cancel', # TODO remove it and wrap it with a wizard giving a warning. ] def default_state(self, cursor, user, context=None): @@ -203,3 +202,38 @@ class CompleteInventory(Wizard): return {} CompleteInventory() + +class CancelInventoryInit(WizardOSV): + _name = 'stock.inventory.cancel.init' +CancelInventoryInit() + +class CancelInventory(Wizard): + 'Cancel Inventory' + _name = 'stock.inventory.cancel' + states = { + 'init': { + 'result': { + 'type': 'form', + 'object': 'stock.inventory.cancel.init', + 'state': [ + ('end', 'Cancel', 'gtk-cancel'), + ('cancel', 'Ok', 'gtk-ok', True), + ], + }, + }, + 'cancel': { + 'result': { + 'type': 'action', + 'action': '_action_cancel', + 'state': 'end', + }, + }, + } + + def _action_cancel(self, cursor, user, data, context=None): + inventory_obj = self.pool.get('stock.inventory') + inventory_obj.set_state_cancel( + cursor, user, data['ids'], context=context) + return {} + +CancelInventory() diff --git a/inventory.xml b/inventory.xml index 95ef277528..341dd9f875 100644 --- a/inventory.xml +++ b/inventory.xml @@ -1,6 +1,24 @@ + + + stock.inventory.cancel.init + form + + + + + + + Cancel Inventory + stock.inventory.cancel + + stock.inventory form @@ -22,7 +40,7 @@ states="{'invisible': '''state in ('done','cancel') '''}"/>