parent
9d06ab51c6
commit
e9b1e6aa85
20
operation.py
20
operation.py
|
@ -41,7 +41,7 @@ class Operation(sequence_ordered(), Workflow, ModelSQL, ModelView):
|
||||||
operation_type = fields.Many2One('production.operation.type',
|
operation_type = fields.Many2One('production.operation.type',
|
||||||
'Operation Type', states=STATES, depends=DEPENDS, required=True)
|
'Operation Type', states=STATES, depends=DEPENDS, required=True)
|
||||||
state = fields.Selection([
|
state = fields.Selection([
|
||||||
('cancel', 'Canceled'),
|
('cancelled', 'Canceled'),
|
||||||
('planned', 'Planned'),
|
('planned', 'Planned'),
|
||||||
('waiting', 'Waiting'),
|
('waiting', 'Waiting'),
|
||||||
('running', 'Running'),
|
('running', 'Running'),
|
||||||
|
@ -55,7 +55,7 @@ class Operation(sequence_ordered(), Workflow, ModelSQL, ModelView):
|
||||||
super(Operation, cls).__setup__()
|
super(Operation, cls).__setup__()
|
||||||
cls._invalid_production_states_on_create = ['done']
|
cls._invalid_production_states_on_create = ['done']
|
||||||
cls._transitions |= set((
|
cls._transitions |= set((
|
||||||
('planned', 'cancel'),
|
('planned', 'cancelled'),
|
||||||
('planned', 'waiting'),
|
('planned', 'waiting'),
|
||||||
('waiting', 'running'),
|
('waiting', 'running'),
|
||||||
('running', 'waiting'),
|
('running', 'waiting'),
|
||||||
|
@ -79,6 +79,18 @@ class Operation(sequence_ordered(), Workflow, ModelSQL, ModelView):
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def __register__(cls, module_name):
|
||||||
|
cursor = Transaction().connection.cursor()
|
||||||
|
sql_table = cls.__table__()
|
||||||
|
|
||||||
|
super(Operation, cls).__register__(module_name)
|
||||||
|
|
||||||
|
# Migration from 5.6: rename state cancel to cancelled
|
||||||
|
cursor.execute(*sql_table.update(
|
||||||
|
[sql_table.state], ['cancelled'],
|
||||||
|
where=sql_table.state == 'cancel'))
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def default_state():
|
def default_state():
|
||||||
return 'planned'
|
return 'planned'
|
||||||
|
@ -155,7 +167,7 @@ class Operation(sequence_ordered(), Workflow, ModelSQL, ModelView):
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
@ModelView.button
|
@ModelView.button
|
||||||
@Workflow.transition('cancel')
|
@Workflow.transition('cancelled')
|
||||||
def cancel(cls, operations):
|
def cancel(cls, operations):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
@ -302,7 +314,7 @@ class Production(metaclass=PoolMeta):
|
||||||
if config.check_state_operation:
|
if config.check_state_operation:
|
||||||
pending_operations = Operation.search([
|
pending_operations = Operation.search([
|
||||||
('production', 'in', [p.id for p in productions]),
|
('production', 'in', [p.id for p in productions]),
|
||||||
('state', 'not in', ['cancel', 'done']),
|
('state', 'not in', ['cancelled', 'done']),
|
||||||
], limit=1)
|
], limit=1)
|
||||||
if pending_operations:
|
if pending_operations:
|
||||||
operation, = pending_operations
|
operation, = pending_operations
|
||||||
|
|
Loading…
Reference in New Issue