diff --git a/locale/ca.po b/locale/ca.po
index 3098b63..8fe5c66 100644
--- a/locale/ca.po
+++ b/locale/ca.po
@@ -415,6 +415,10 @@ msgctxt "selection:production.configuration,check_state_operation:"
msgid "User Warning"
msgstr "Alerta usuari"
+msgctxt "selection:production.operation,state:"
+msgid "Canceled"
+msgstr "Cancel·lada"
+
msgctxt "selection:production.operation,state:"
msgid "Done"
msgstr "Realitzat"
diff --git a/locale/es.po b/locale/es.po
index cf54baf..7bcd9c1 100644
--- a/locale/es.po
+++ b/locale/es.po
@@ -416,6 +416,10 @@ msgctxt "selection:production.configuration,check_state_operation:"
msgid "User Warning"
msgstr "Alerta usuario"
+msgctxt "selection:production.operation,state:"
+msgid "Canceled"
+msgstr "Cancelada"
+
msgctxt "selection:production.operation,state:"
msgid "Done"
msgstr "Realizado"
diff --git a/operation.py b/operation.py
index eefef9d..640cb95 100644
--- a/operation.py
+++ b/operation.py
@@ -41,6 +41,7 @@ class Operation(sequence_ordered(), Workflow, ModelSQL, ModelView):
operation_type = fields.Many2One('production.operation.type',
'Operation Type', states=STATES, depends=DEPENDS, required=True)
state = fields.Selection([
+ ('cancel', 'Canceled'),
('planned', 'Planned'),
('waiting', 'Waiting'),
('running', 'Running'),
@@ -54,12 +55,16 @@ class Operation(sequence_ordered(), Workflow, ModelSQL, ModelView):
super(Operation, cls).__setup__()
cls._invalid_production_states_on_create = ['done']
cls._transitions |= set((
+ ('planned', 'cancel'),
('planned', 'waiting'),
('waiting', 'running'),
('running', 'waiting'),
('running', 'done'),
))
cls._buttons.update({
+ 'cancel': {
+ 'invisible': Eval('state') != 'planned',
+ },
'wait': {
'invisible': ~Eval('state').in_(['planned', 'running']),
'icon': If(Eval('state') == 'running',
@@ -148,6 +153,12 @@ class Operation(sequence_ordered(), Workflow, ModelSQL, ModelView):
self.work_center_category.uom)
return total
+ @classmethod
+ @ModelView.button
+ @Workflow.transition('cancel')
+ def cancel(cls, operations):
+ pass
+
@classmethod
@ModelView.button
@Workflow.transition('waiting')
@@ -300,7 +311,7 @@ class Production(metaclass=PoolMeta):
if config.check_state_operation:
pending_operations = Operation.search([
('production', 'in', [p.id for p in productions]),
- ('state', '!=', 'done'),
+ ('state', 'not in', ['cancel', 'done']),
], limit=1)
if pending_operations:
operation, = pending_operations
diff --git a/operation.xml b/operation.xml
index ac4ad80..8b9c0a6 100644
--- a/operation.xml
+++ b/operation.xml
@@ -95,6 +95,11 @@
+
+ cancel
+ Cancel
+
+
wait
Wait
diff --git a/view/operation_form.xml b/view/operation_form.xml
index b743148..bdf6e8b 100644
--- a/view/operation_form.xml
+++ b/view/operation_form.xml
@@ -21,6 +21,7 @@
+