Adding wizard around inventory cancellation function.
This commit is contained in:
1 parent
b21a813d56
commit
a2f9b86b85
2 files changed
+54
-2
No files matched your search
+35
-1
@@ -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()
|
||||
+19
-1
@@ -1,6 +1,24 @@
|
||||
<?xml version="1.0"?>
|
||||
<tryton>
|
||||
<data>
|
||||
|
||||
<record model="ir.ui.view" id="inventory_select_init_view_form">
|
||||
<field name="model">stock.inventory.cancel.init</field>
|
||||
<field name="type">form</field>
|
||||
<field name="arch" type="xml">
|
||||
<![CDATA[
|
||||
<form string="Cancel Inventory" col="1">
|
||||
<separator string="Warning"/>
|
||||
<label string="All generated moves will be cancelled."/>
|
||||
</form>
|
||||
]]>
|
||||
</field>
|
||||
</record>
|
||||
<record model="ir.action.wizard" id="wizard_inventory_cancel">
|
||||
<field name="name">Cancel Inventory</field>
|
||||
<field name="wiz_name">stock.inventory.cancel</field>
|
||||
</record>
|
||||
|
||||
<record model="ir.ui.view" id="inventory_view_form">
|
||||
<field name="model">stock.inventory</field>
|
||||
<field name="type">form</field>
|
||||
@@ -22,7 +40,7 @@
|
||||
states="{'invisible': '''state in
|
||||
('done','cancel') '''}"/>
|
||||
<button string="Cancel"
|
||||
name="set_state_cancel" type="object"
|
||||
name="%(wizard_inventory_cancel)d" type="action"
|
||||
states="{'invisible': '''state in
|
||||
('open','cancel') '''}"/>
|
||||
</group>
|
||||
|
||||
Reference in new issue
Block a user