From 3ffaa5146d643091a801c2b456219d53410148ba Mon Sep 17 00:00:00 2001 From: alfredo Date: Tue, 3 Mar 2015 15:04:49 +0100 Subject: [PATCH] [IMP] mrp_operations_extension: Has gotten mrp_operation_produce programming module. closses #644. --- mrp_operations_extension/README.rst | 3 + mrp_operations_extension/i18n/es.po | 97 ++++++++++++++++--- .../i18n/mrp_operations_extension.pot | 79 +++++++++++++-- .../models/mrp_production.py | 54 +++++++++++ .../models/mrp_routing.py | 10 ++ .../views/mrp_production_view.xml | 9 ++ .../views/mrp_routing_view.xml | 15 ++- 7 files changed, 244 insertions(+), 23 deletions(-) diff --git a/mrp_operations_extension/README.rst b/mrp_operations_extension/README.rst index 991538ecc..2ef8f8b32 100644 --- a/mrp_operations_extension/README.rst +++ b/mrp_operations_extension/README.rst @@ -7,3 +7,6 @@ This module adds: - Adds a relation from WorkcenterLines to BoM Lists. - Adds a relation from WorkcenterLines to Manufacturing Orders in Scheduled/Consumed/Finished Products. - Adds a relation between Routing Work Center Lines and Work Center extra Info. + +Controls the availability of material in operations, and controls operation +start with respect to previous. diff --git a/mrp_operations_extension/i18n/es.po b/mrp_operations_extension/i18n/es.po index 94da58748..24fa42bad 100644 --- a/mrp_operations_extension/i18n/es.po +++ b/mrp_operations_extension/i18n/es.po @@ -6,13 +6,13 @@ msgid "" msgstr "" "Project-Id-Version: Odoo Server 8.0\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2015-01-18 12:06+0000\n" -"PO-Revision-Date: 2015-01-18 12:06+0000\n" -"Last-Translator: <>\n" +"POT-Creation-Date: 2015-03-03 13:44+0000\n" +"PO-Revision-Date: 2015-03-03 14:53+0100\n" +"Last-Translator: Alfredo \n" "Language-Team: \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" -"Content-Transfer-Encoding: \n" +"Content-Transfer-Encoding: 8bit\n" "Plural-Forms: \n" #. module: mrp_operations_extension @@ -28,7 +28,7 @@ msgid "Actual Production Date" msgstr "Fecha real de producción" #. module: mrp_operations_extension -#: code:addons/mrp_operations_extension/models/mrp_production.py:29 +#: code:addons/mrp_operations_extension/models/mrp_production.py:51 #, python-format msgid "At least one work order must have checked 'Produce here'" msgstr "Al menos una orden de trabajo debe tener marcada 'Producir aquí'" @@ -36,7 +36,7 @@ msgstr "Al menos una orden de trabajo debe tener marcada 'Producir aquí'" #. module: mrp_operations_extension #: model:ir.model,name:mrp_operations_extension.model_mrp_bom msgid "Bill of Material" -msgstr "Lista de materiales" +msgstr "Lista de material" #. module: mrp_operations_extension #: view:mrp.work.order.produce:mrp_operations_extension.view_mrp_product_consume_wizard @@ -55,17 +55,23 @@ msgid "Capacity per cycle" msgstr "Capacidad por ciclo" #. module: mrp_operations_extension -#: code:addons/mrp_operations_extension/models/mrp_bom.py:67 +#: code:addons/mrp_operations_extension/models/mrp_bom.py:72 #, python-format msgid "Changing Routing" msgstr "Cambiando ruta" #. module: mrp_operations_extension -#: code:addons/mrp_operations_extension/models/mrp_bom.py:68 +#: code:addons/mrp_operations_extension/models/mrp_bom.py:73 #, python-format msgid "Changing routing will cause to change the operation in which each component will be consumed, by default it is set the first one of the routing" msgstr "Cambiar la ruta causará que cambie la operación en la que cada componente se consumirá. Por defecto se establece la primera de la ruta." +#. module: mrp_operations_extension +#: view:mrp.production:mrp_operations_extension.mrp_production_operation_buttons_form_view +#: view:mrp.production.workcenter.line:mrp_operations_extension.workcenter_line_inh_form_view +msgid "Check Availability" +msgstr "Comprobar disponibilidad" + #. module: mrp_operations_extension #: field:mrp.routing.operation,code:0 msgid "Code" @@ -151,6 +157,12 @@ msgstr "Información extra" msgid "Final Product to Stock" msgstr "Producto final a existencias" +#. module: mrp_operations_extension +#: view:mrp.production:mrp_operations_extension.mrp_production_operation_buttons_form_view +#: view:mrp.production.workcenter.line:mrp_operations_extension.workcenter_line_inh_form_view +msgid "Force Reservation" +msgstr "Forzar reservas" + #. module: mrp_operations_extension #: field:mrp.operation.workcenter,id:0 #: field:mrp.routing.operation,id:0 @@ -208,21 +220,49 @@ msgstr "Gestionar operadores en los centros de trabajo" msgid "Manufacturing Operators" msgstr "Operadores de fabricación" +#. module: mrp_operations_extension +#: model:ir.model,name:mrp_operations_extension.model_mrp_production +msgid "Manufacturing Order" +msgstr "Órden de producción" + #. module: mrp_operations_extension #: view:mrp.production:mrp_operations_extension.mrp_production_form_view_inh msgid "Materials" msgstr "Materiales" +#. module: mrp_operations_extension +#: code:addons/mrp_operations_extension/models/mrp_production.py:142 +#, python-format +msgid "Missing materials" +msgstr "Esperando materiales" + +#. module: mrp_operations_extension +#: code:addons/mrp_operations_extension/models/mrp_production.py:143 +#, python-format +msgid "Missing materials to start the production" +msgstr "Esperando materiales para empezar la producción" + #. module: mrp_operations_extension #: field:mrp.work.order.produce,mode:0 msgid "Mode" msgstr "Modo" +#. module: mrp_operations_extension +#: field:mrp.production.workcenter.line,move_lines:0 +msgid "Moves" +msgstr "Moves" + #. module: mrp_operations_extension #: field:mrp.routing.operation,name:0 msgid "Name" msgstr "Nombre" +#. module: mrp_operations_extension +#: code:addons/mrp_operations_extension/models/mrp_production.py:138 +#, python-format +msgid "Not finished operations" +msgstr "Operaciones no finalizadas" + #. module: mrp_operations_extension #: field:mrp.routing.workcenter,operation:0 msgid "Operation" @@ -280,6 +320,18 @@ msgstr "Producto de coste de post-operación" msgid "Pre-operation costing product" msgstr "Producto de coste de pre-operación" +#. module: mrp_operations_extension +#: field:mrp.routing,previous_operations_finished:0 +#: field:mrp.routing.workcenter,previous_operations_finished:0 +msgid "Previous operations finished" +msgstr "Operaciones previsas terminadas" + +#. module: mrp_operations_extension +#: code:addons/mrp_operations_extension/models/mrp_production.py:139 +#, python-format +msgid "Previous operations not finished" +msgstr "Operaciones previas no terminadas" + #. module: mrp_operations_extension #: model:ir.actions.act_window,name:mrp_operations_extension.act_mrp_work_order_produce #: view:mrp.production:mrp_operations_extension.mrp_production_operation_buttons_form_view @@ -287,7 +339,7 @@ msgstr "Producto de coste de pre-operación" #: view:mrp.work.order.produce:mrp_operations_extension.view_mrp_product_consume_wizard #: view:mrp.work.order.produce:mrp_operations_extension.view_mrp_product_produce_wizard msgid "Produce" -msgstr "Producir" +msgstr "Fabricar" #. module: mrp_operations_extension #: field:mrp.production.workcenter.line,do_production:0 @@ -310,7 +362,7 @@ msgstr "Líneas de producto" #. module: mrp_operations_extension #: model:ir.model,name:mrp_operations_extension.model_mrp_product_produce_line msgid "Product Produce Consume lines" -msgstr "Líneas de consumo de productos producidos" +msgstr "Líneas de consumo de los producto producidos" #. module: mrp_operations_extension #: view:mrp.production:mrp_operations_extension.mrp_production_form_view_inh @@ -321,7 +373,7 @@ msgstr "Producto a producir" #. module: mrp_operations_extension #: model:ir.model,name:mrp_operations_extension.model_mrp_production_product_line msgid "Production Scheduled Product" -msgstr "Producto planificado de producción" +msgstr "Fabricación planificada producto" #. module: mrp_operations_extension #: field:mrp.work.order.produce,consume_lines:0 @@ -336,7 +388,7 @@ msgstr "Pasos relevantes" #. module: mrp_operations_extension #: model:ir.model,name:mrp_operations_extension.model_mrp_routing msgid "Routing" -msgstr "Ruta" +msgstr "Proceso productivo" #. module: mrp_operations_extension #: model:ir.actions.act_window,name:mrp_operations_extension.mrp_routing_operation_action @@ -372,7 +424,7 @@ msgid "Stock Move" msgstr "Movimiento de existencias" #. module: mrp_operations_extension -#: code:addons/mrp_operations_extension/models/mrp_routing.py:57 +#: code:addons/mrp_operations_extension/models/mrp_routing.py:67 #, python-format msgid "There must be one and only one line set as default." msgstr "Debe haber una y sólo una línea marcado como por defecto." @@ -383,6 +435,16 @@ msgstr "Debe haber una y sólo una línea marcado como por defecto." msgid "There must be one and only one operation with 'Produce here' check marked." msgstr "Debe haber una y sólo una operación con la casilla 'Producir aquí' marcada." +#. module: mrp_operations_extension +#: field:mrp.production.workcenter.line,time_start:0 +msgid "Time Start" +msgstr "Hora inicio" + +#. module: mrp_operations_extension +#: field:mrp.production.workcenter.line,time_stop:0 +msgid "Time Stop" +msgstr "Hora parada" + #. module: mrp_operations_extension #: field:mrp.operation.workcenter,time_stop:0 msgid "Time after prod." @@ -419,6 +481,11 @@ msgstr "Tiempo en horas para la preparación" msgid "To Consume" msgstr "A consumir" +#. module: mrp_operations_extension +#: view:mrp.routing.workcenter:mrp_operations_extension.mrp_routing_workcenter_tree_view_inh +msgid "Total" +msgstr "Total" + #. module: mrp_operations_extension #: field:mrp.work.order.produce,track_production:0 msgid "Track production" @@ -427,12 +494,12 @@ msgstr "Rastrear producción" #. module: mrp_operations_extension #: model:ir.model,name:mrp_operations_extension.model_mrp_workcenter msgid "Work Center" -msgstr "Centro de trabajo" +msgstr "Centro de producción" #. module: mrp_operations_extension #: model:ir.model,name:mrp_operations_extension.model_mrp_routing_workcenter msgid "Work Center Usage" -msgstr "Uso del centro de trabajo" +msgstr "Utilización del centro de producción" #. module: mrp_operations_extension #: model:ir.model,name:mrp_operations_extension.model_mrp_production_workcenter_line diff --git a/mrp_operations_extension/i18n/mrp_operations_extension.pot b/mrp_operations_extension/i18n/mrp_operations_extension.pot index a4d8b72b7..51ebb7045 100644 --- a/mrp_operations_extension/i18n/mrp_operations_extension.pot +++ b/mrp_operations_extension/i18n/mrp_operations_extension.pot @@ -6,8 +6,8 @@ msgid "" msgstr "" "Project-Id-Version: Odoo Server 8.0\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2015-01-18 12:06+0000\n" -"PO-Revision-Date: 2015-01-18 12:06+0000\n" +"POT-Creation-Date: 2015-03-03 13:44+0000\n" +"PO-Revision-Date: 2015-03-03 13:44+0000\n" "Last-Translator: <>\n" "Language-Team: \n" "MIME-Version: 1.0\n" @@ -28,7 +28,7 @@ msgid "Actual Production Date" msgstr "" #. module: mrp_operations_extension -#: code:addons/mrp_operations_extension/models/mrp_production.py:29 +#: code:addons/mrp_operations_extension/models/mrp_production.py:51 #, python-format msgid "At least one work order must have checked 'Produce here'" msgstr "" @@ -55,17 +55,23 @@ msgid "Capacity per cycle" msgstr "" #. module: mrp_operations_extension -#: code:addons/mrp_operations_extension/models/mrp_bom.py:67 +#: code:addons/mrp_operations_extension/models/mrp_bom.py:72 #, python-format msgid "Changing Routing" msgstr "" #. module: mrp_operations_extension -#: code:addons/mrp_operations_extension/models/mrp_bom.py:68 +#: code:addons/mrp_operations_extension/models/mrp_bom.py:73 #, python-format msgid "Changing routing will cause to change the operation in which each component will be consumed, by default it is set the first one of the routing" msgstr "" +#. module: mrp_operations_extension +#: view:mrp.production:mrp_operations_extension.mrp_production_operation_buttons_form_view +#: view:mrp.production.workcenter.line:mrp_operations_extension.workcenter_line_inh_form_view +msgid "Check Availability" +msgstr "" + #. module: mrp_operations_extension #: field:mrp.routing.operation,code:0 msgid "Code" @@ -151,6 +157,12 @@ msgstr "" msgid "Final Product to Stock" msgstr "" +#. module: mrp_operations_extension +#: view:mrp.production:mrp_operations_extension.mrp_production_operation_buttons_form_view +#: view:mrp.production.workcenter.line:mrp_operations_extension.workcenter_line_inh_form_view +msgid "Force Reservation" +msgstr "" + #. module: mrp_operations_extension #: field:mrp.operation.workcenter,id:0 #: field:mrp.routing.operation,id:0 @@ -208,21 +220,49 @@ msgstr "" msgid "Manufacturing Operators" msgstr "" +#. module: mrp_operations_extension +#: model:ir.model,name:mrp_operations_extension.model_mrp_production +msgid "Manufacturing Order" +msgstr "" + #. module: mrp_operations_extension #: view:mrp.production:mrp_operations_extension.mrp_production_form_view_inh msgid "Materials" msgstr "" +#. module: mrp_operations_extension +#: code:addons/mrp_operations_extension/models/mrp_production.py:142 +#, python-format +msgid "Missing materials" +msgstr "" + +#. module: mrp_operations_extension +#: code:addons/mrp_operations_extension/models/mrp_production.py:143 +#, python-format +msgid "Missing materials to start the production" +msgstr "" + #. module: mrp_operations_extension #: field:mrp.work.order.produce,mode:0 msgid "Mode" msgstr "" +#. module: mrp_operations_extension +#: field:mrp.production.workcenter.line,move_lines:0 +msgid "Moves" +msgstr "" + #. module: mrp_operations_extension #: field:mrp.routing.operation,name:0 msgid "Name" msgstr "" +#. module: mrp_operations_extension +#: code:addons/mrp_operations_extension/models/mrp_production.py:138 +#, python-format +msgid "Not finished operations" +msgstr "" + #. module: mrp_operations_extension #: field:mrp.routing.workcenter,operation:0 msgid "Operation" @@ -280,6 +320,18 @@ msgstr "" msgid "Pre-operation costing product" msgstr "" +#. module: mrp_operations_extension +#: field:mrp.routing,previous_operations_finished:0 +#: field:mrp.routing.workcenter,previous_operations_finished:0 +msgid "Previous operations finished" +msgstr "" + +#. module: mrp_operations_extension +#: code:addons/mrp_operations_extension/models/mrp_production.py:139 +#, python-format +msgid "Previous operations not finished" +msgstr "" + #. module: mrp_operations_extension #: model:ir.actions.act_window,name:mrp_operations_extension.act_mrp_work_order_produce #: view:mrp.production:mrp_operations_extension.mrp_production_operation_buttons_form_view @@ -372,7 +424,7 @@ msgid "Stock Move" msgstr "" #. module: mrp_operations_extension -#: code:addons/mrp_operations_extension/models/mrp_routing.py:57 +#: code:addons/mrp_operations_extension/models/mrp_routing.py:67 #, python-format msgid "There must be one and only one line set as default." msgstr "" @@ -383,6 +435,16 @@ msgstr "" msgid "There must be one and only one operation with 'Produce here' check marked." msgstr "" +#. module: mrp_operations_extension +#: field:mrp.production.workcenter.line,time_start:0 +msgid "Time Start" +msgstr "" + +#. module: mrp_operations_extension +#: field:mrp.production.workcenter.line,time_stop:0 +msgid "Time Stop" +msgstr "" + #. module: mrp_operations_extension #: field:mrp.operation.workcenter,time_stop:0 msgid "Time after prod." @@ -419,6 +481,11 @@ msgstr "" msgid "To Consume" msgstr "" +#. module: mrp_operations_extension +#: view:mrp.routing.workcenter:mrp_operations_extension.mrp_routing_workcenter_tree_view_inh +msgid "Total" +msgstr "" + #. module: mrp_operations_extension #: field:mrp.work.order.produce,track_production:0 msgid "Track production" diff --git a/mrp_operations_extension/models/mrp_production.py b/mrp_operations_extension/models/mrp_production.py index c7cabfde6..f0e330e45 100644 --- a/mrp_operations_extension/models/mrp_production.py +++ b/mrp_operations_extension/models/mrp_production.py @@ -22,6 +22,26 @@ from openerp import models, fields, api, exceptions, _ class MrpProduction(models.Model): _inherit = 'mrp.production' + def _get_minor_sequence_operation(self, operations): + if operations and len(operations) > 1: + minor_operation = operations[0] + for operation in operations[1:]: + if minor_operation.sequence > operation: + minor_operation = operation + return minor_operation + else: + return operations and operations[0] + + @api.model + def _moves_assigned(self): + res = super(MrpProduction, self)._moves_assigned() + if res: + return True + operation = self._get_minor_sequence_operation(self.workcenter_lines) + assigned_moves, no_assigned_products = \ + self._get_operation_moves(operation, state='assigned') + return no_assigned_products == [] + @api.multi def action_confirm(self): res = super(MrpProduction, self).action_confirm() @@ -88,3 +108,37 @@ class MrpProductionWorkcenterLine(models.Model): do_production = fields.Boolean(string='Produce here') time_start = fields.Float(string="Time Start") time_stop = fields.Float(string="Time Stop") + move_lines = fields.One2many('stock.move', 'work_order', + string='Moves') + + @api.one + def action_assign(self): + self.move_lines.action_assign() + + @api.one + def force_assign(self): + self.move_lines.force_assign() + + def check_minor_sequence_operations(self): + seq = self.sequence + for operation in self.production_id.workcenter_lines: + if operation.sequence < seq and operation.state != 'done': + return False + return True + + def check_operation_moves_state(self, state): + for move_line in self.move_lines: + if move_line.state != state: + return False + return True + + def action_start_working(self): + if self.routing_wc_line.previous_operations_finished and \ + not self.check_minor_sequence_operations(): + raise exceptions.Warning(_("Not finished operations"), + _("Previous operations not finished")) + if not self.check_operation_moves_state('assigned'): + raise exceptions.Warning( + _("Missing materials"), + _("Missing materials to start the production")) + return super(MrpProductionWorkcenterLine, self).action_start_working() diff --git a/mrp_operations_extension/models/mrp_routing.py b/mrp_operations_extension/models/mrp_routing.py index 6bb226f73..474ac7d02 100644 --- a/mrp_operations_extension/models/mrp_routing.py +++ b/mrp_operations_extension/models/mrp_routing.py @@ -33,10 +33,17 @@ class MrpRouting(models.Model): raise Warning(_("There must be one and only one operation with " "'Produce here' check marked.")) + previous_operations_finished = fields.Boolean( + string='Previous operations finished') + class MrpRoutingWorkcenter(models.Model): _inherit = 'mrp.routing.workcenter' + def get_routing_previous_operations(self): + self.previous_operations_finished = \ + self.routing_id.previous_operations_finished + operation = fields.Many2one('mrp.routing.operation', string='Operation') op_wc_lines = fields.One2many( 'mrp.operation.workcenter', 'routing_workcenter', @@ -46,6 +53,9 @@ class MrpRoutingWorkcenter(models.Model): help="If enabled, the production and movement to stock of the final " "products will be done in this operation. There can be only one " "operation per route with this check marked.") + previous_operations_finished = fields.Boolean( + string='Previous operations finished', + default="get_routing_previous_operations") @api.constrains('op_wc_lines') def _check_default_op_wc_lines(self): diff --git a/mrp_operations_extension/views/mrp_production_view.xml b/mrp_operations_extension/views/mrp_production_view.xml index 2ea1314fa..2fe53b0b9 100644 --- a/mrp_operations_extension/views/mrp_production_view.xml +++ b/mrp_operations_extension/views/mrp_production_view.xml @@ -137,6 +137,10 @@