From 7bdf72ad285907df12b0cc1bc27b830eacae3632 Mon Sep 17 00:00:00 2001 From: Bernat Brunet Date: Thu, 6 Oct 2022 13:57:13 +0200 Subject: [PATCH] Allow to choose by configuration if a production will be done with the last operation done. --- configuration.py | 6 ++++++ locale/ca.po | 8 ++++++++ locale/es.po | 9 +++++++++ operation.py | 5 ++++- view/configuration_form.xml | 2 ++ 5 files changed, 29 insertions(+), 1 deletion(-) diff --git a/configuration.py b/configuration.py index fd0e87c..4c27d67 100644 --- a/configuration.py +++ b/configuration.py @@ -12,7 +12,13 @@ class Configuration(metaclass=PoolMeta): ('user_error', 'User Error'), ], 'Check State Operation', help='Check state operation when done a production') + allow_done_production = fields.Boolean('Allow Done Produciton', + help='Allow done the productoin when finish the last operation') @staticmethod def default_check_state_operation(): return 'user_error' + + @staticmethod + def default_allow_done_production(): + return True diff --git a/locale/ca.po b/locale/ca.po index b40da9d..b21583e 100644 --- a/locale/ca.po +++ b/locale/ca.po @@ -14,6 +14,10 @@ msgctxt "field:production.configuration,check_state_operation:" msgid "Check State Operation" msgstr "Comprovar estat operació" +msgctxt "field:production.configuration,allow_done_production:" +msgid "Allow Done Produciton" +msgstr "Permetre realitzar producció" + msgctxt "field:production.operation,company:" msgid "Company" msgstr "Empresa" @@ -130,6 +134,10 @@ msgctxt "help:production.configuration,check_state_operation:" msgid "Check state operation when done a production" msgstr "Comprova l'estat de les operacions quan es finalitza una producció" +msgctxt "help:production.configuration,allow_done_production:" +msgid "Allow done the productoin when finish the last operation" +msgstr "Permentre finalitzar la producció quan es finalitza l'última operació" + msgctxt "model:ir.action,name:" msgid "Operation Type" msgstr "Tipus d'operació" diff --git a/locale/es.po b/locale/es.po index 748e235..bcbed69 100644 --- a/locale/es.po +++ b/locale/es.po @@ -14,6 +14,10 @@ msgctxt "field:production.configuration,check_state_operation:" msgid "Check State Operation" msgstr "Comprobar estado operación" +msgctxt "field:production.configuration,allow_done_production:" +msgid "Allow Done Produciton" +msgstr "Permitir realizar producción" + msgctxt "field:production.operation,company:" msgid "Company" msgstr "Empresa" @@ -131,6 +135,11 @@ msgid "Check state operation when done a production" msgstr "" "Comprueba el estado de las operaciones cuando se finaliza una producción" +msgctxt "help:production.configuration,allow_done_production:" +msgid "Allow done the productoin when finish the last operation" +msgstr "" +"Permitir finalizar la producción cuando se finaliza la última operación" + msgctxt "model:ir.action,name:" msgid "Operation Type" msgstr "Tipo de operación" diff --git a/operation.py b/operation.py index 436a5cf..2caf961 100644 --- a/operation.py +++ b/operation.py @@ -189,6 +189,8 @@ class Operation(sequence_ordered(), Workflow, ModelSQL, ModelView): def done(cls, operations): pool = Pool() Production = pool.get('production') + Config = pool.get('production.configuration') + config = Config(1) productions = set([o.production for o in operations]) cls.write(operations, {'state': 'done'}) @@ -201,7 +203,8 @@ class Operation(sequence_ordered(), Workflow, ModelSQL, ModelView): break if to_do: to_done.append(production) - Production.done(to_done) + if config.allow_done_production: + Production.done(to_done) class OperationTracking(ModelSQL, ModelView): diff --git a/view/configuration_form.xml b/view/configuration_form.xml index dfb29ce..537897e 100644 --- a/view/configuration_form.xml +++ b/view/configuration_form.xml @@ -6,5 +6,7 @@