From 8a3b2fee59ee58302b437b5bc521063f9fe4ba4b Mon Sep 17 00:00:00 2001 From: Tu Nombre Date: Tue, 8 Oct 2024 11:53:45 +0200 Subject: [PATCH] [14.0][IMP] custom_mrp_descarga: Add new fields in production. --- custom_mrp_descarga/__manifest__.py | 1 + .../i18n/custom_mrp_descarga.pot | 44 ++++++++++++++++++- custom_mrp_descarga/i18n/es.po | 44 ++++++++++++++++++- custom_mrp_descarga/models/__init__.py | 1 + custom_mrp_descarga/models/mrp_production.py | 44 ++++++++++++++++--- custom_mrp_descarga/models/mrp_workorder.py | 29 ++++++++++++ .../models/stock_inventory_line.py | 2 +- .../views/mrp_production_view.xml | 32 +++++++++++++- .../views/mrp_workorder_view.xml | 19 ++++++++ 9 files changed, 204 insertions(+), 12 deletions(-) create mode 100644 custom_mrp_descarga/models/mrp_workorder.py create mode 100644 custom_mrp_descarga/views/mrp_workorder_view.xml diff --git a/custom_mrp_descarga/__manifest__.py b/custom_mrp_descarga/__manifest__.py index 378810b7f..8dfcc2551 100644 --- a/custom_mrp_descarga/__manifest__.py +++ b/custom_mrp_descarga/__manifest__.py @@ -30,6 +30,7 @@ "data/ir_cron_data.xml", "views/saca_line_view.xml", "views/mrp_production_view.xml", + "views/mrp_workorder_view.xml", "views/stock_production_lot_view.xml", "views/stock_quant_view.xml", "views/mrp_bom_view.xml", diff --git a/custom_mrp_descarga/i18n/custom_mrp_descarga.pot b/custom_mrp_descarga/i18n/custom_mrp_descarga.pot index 863a7e076..f34cb6352 100644 --- a/custom_mrp_descarga/i18n/custom_mrp_descarga.pot +++ b/custom_mrp_descarga/i18n/custom_mrp_descarga.pot @@ -6,8 +6,8 @@ msgid "" msgstr "" "Project-Id-Version: Odoo Server 14.0\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-09-11 12:55+0000\n" -"PO-Revision-Date: 2024-09-11 12:55+0000\n" +"POT-Creation-Date: 2024-10-22 09:12+0000\n" +"PO-Revision-Date: 2024-10-22 09:12+0000\n" "Last-Translator: \n" "Language-Team: \n" "MIME-Version: 1.0\n" @@ -260,6 +260,7 @@ msgstr "" #: model:ir.model.fields,field_description:custom_mrp_descarga.field_account_analytic_line__display_name #: model:ir.model.fields,field_description:custom_mrp_descarga.field_mrp_bom__display_name #: model:ir.model.fields,field_description:custom_mrp_descarga.field_mrp_production__display_name +#: model:ir.model.fields,field_description:custom_mrp_descarga.field_mrp_workorder__display_name #: model:ir.model.fields,field_description:custom_mrp_descarga.field_product_template__display_name #: model:ir.model.fields,field_description:custom_mrp_descarga.field_project_task__display_name #: model:ir.model.fields,field_description:custom_mrp_descarga.field_report_mrp_production_quartering_summary_xlsx__display_name @@ -278,6 +279,11 @@ msgstr "" msgid "Don't produce the header product" msgstr "" +#. module: custom_mrp_descarga +#: model:ir.model.fields,field_description:custom_mrp_descarga.field_stock_move_line__qty_done +msgid "Done" +msgstr "" + #. module: custom_mrp_descarga #: model_terms:ir.ui.view,arch_db:custom_mrp_descarga.stock_move_line_view_search msgid "Done bigger than 0" @@ -369,6 +375,7 @@ msgstr "" #: model:ir.model.fields,field_description:custom_mrp_descarga.field_account_analytic_line__id #: model:ir.model.fields,field_description:custom_mrp_descarga.field_mrp_bom__id #: model:ir.model.fields,field_description:custom_mrp_descarga.field_mrp_production__id +#: model:ir.model.fields,field_description:custom_mrp_descarga.field_mrp_workorder__id #: model:ir.model.fields,field_description:custom_mrp_descarga.field_product_template__id #: model:ir.model.fields,field_description:custom_mrp_descarga.field_project_task__id #: model:ir.model.fields,field_description:custom_mrp_descarga.field_report_mrp_production_quartering_summary_xlsx__id @@ -400,6 +407,11 @@ msgstr "" msgid "Input Products" msgstr "" +#. module: custom_mrp_descarga +#: model:ir.model.fields,field_description:custom_mrp_descarga.field_mrp_production__speed_consume_unit +msgid "Input Unit/Hour" +msgstr "" + #. module: custom_mrp_descarga #: model_terms:ir.ui.view,arch_db:custom_mrp_descarga.mrp_bom_form_view #: model_terms:ir.ui.view,arch_db:custom_mrp_descarga.mrp_production_form_view @@ -461,6 +473,7 @@ msgstr "" #: model:ir.model.fields,field_description:custom_mrp_descarga.field_account_analytic_line____last_update #: model:ir.model.fields,field_description:custom_mrp_descarga.field_mrp_bom____last_update #: model:ir.model.fields,field_description:custom_mrp_descarga.field_mrp_production____last_update +#: model:ir.model.fields,field_description:custom_mrp_descarga.field_mrp_workorder____last_update #: model:ir.model.fields,field_description:custom_mrp_descarga.field_product_template____last_update #: model:ir.model.fields,field_description:custom_mrp_descarga.field_project_task____last_update #: model:ir.model.fields,field_description:custom_mrp_descarga.field_report_mrp_production_quartering_summary_xlsx____last_update @@ -628,6 +641,11 @@ msgstr "" msgid "Peso medio" msgstr "" +#. module: custom_mrp_descarga +#: model:ir.model.fields,field_description:custom_mrp_descarga.field_mrp_production__speed_consume_qty +msgid "Produced Kg/Hour" +msgstr "" + #. module: custom_mrp_descarga #: model:ir.model.fields,field_description:custom_mrp_descarga.field_mrp_production__produced_qty msgid "Produced Qty" @@ -852,6 +870,11 @@ msgstr "" msgid "The product of the lot does not match with the product of the line." msgstr "" +#. module: custom_mrp_descarga +#: model:ir.model.fields,field_description:custom_mrp_descarga.field_mrp_production__timesheet_ids +msgid "Timesheet" +msgstr "" + #. module: custom_mrp_descarga #: model_terms:ir.ui.view,arch_db:custom_mrp_descarga.view_mrp_production_filter msgid "Today" @@ -883,6 +906,13 @@ msgstr "" msgid "Total Done" msgstr "" +#. module: custom_mrp_descarga +#: model:ir.model.fields,field_description:custom_mrp_descarga.field_mrp_production__total_duration +#: model:ir.model.fields,field_description:custom_mrp_descarga.field_mrp_workorder__total_duration +#: model_terms:ir.ui.view,arch_db:custom_mrp_descarga.mrp_production_workorder_tree_editable_view +msgid "Total Duration" +msgstr "" + #. module: custom_mrp_descarga #: code:addons/custom_mrp_descarga/report/mrp_production_quartering_summary_xlsx.py:0 #: code:addons/custom_mrp_descarga/report/mrp_production_quartering_summary_xlsx.py:0 @@ -983,11 +1013,21 @@ msgstr "" msgid "Vehicle" msgstr "" +#. module: custom_mrp_descarga +#: model:ir.model.fields,field_description:custom_mrp_descarga.field_mrp_workorder__waiting_duration +msgid "Waiting" +msgstr "" + #. module: custom_mrp_descarga #: model:ir.model.fields,field_description:custom_mrp_descarga.field_mrp_production__waiting_time msgid "Waiting Time" msgstr "" +#. module: custom_mrp_descarga +#: model:ir.model,name:custom_mrp_descarga.model_mrp_workorder +msgid "Work Order" +msgstr "" + #. module: custom_mrp_descarga #: model:ir.ui.menu,name:custom_mrp_descarga.menu_view_workcenter_cost_despiece msgid "Workcenter Cost" diff --git a/custom_mrp_descarga/i18n/es.po b/custom_mrp_descarga/i18n/es.po index 108ece7e7..aedd073de 100644 --- a/custom_mrp_descarga/i18n/es.po +++ b/custom_mrp_descarga/i18n/es.po @@ -6,8 +6,8 @@ msgid "" msgstr "" "Project-Id-Version: Odoo Server 14.0\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-09-11 12:55+0000\n" -"PO-Revision-Date: 2024-09-11 12:55+0000\n" +"POT-Creation-Date: 2024-10-22 09:12+0000\n" +"PO-Revision-Date: 2024-10-22 09:12+0000\n" "Last-Translator: \n" "Language-Team: \n" "MIME-Version: 1.0\n" @@ -262,6 +262,7 @@ msgstr "% diferencia" #: model:ir.model.fields,field_description:custom_mrp_descarga.field_account_analytic_line__display_name #: model:ir.model.fields,field_description:custom_mrp_descarga.field_mrp_bom__display_name #: model:ir.model.fields,field_description:custom_mrp_descarga.field_mrp_production__display_name +#: model:ir.model.fields,field_description:custom_mrp_descarga.field_mrp_workorder__display_name #: model:ir.model.fields,field_description:custom_mrp_descarga.field_product_template__display_name #: model:ir.model.fields,field_description:custom_mrp_descarga.field_project_task__display_name #: model:ir.model.fields,field_description:custom_mrp_descarga.field_report_mrp_production_quartering_summary_xlsx__display_name @@ -280,6 +281,11 @@ msgstr "Mostrar nombre" msgid "Don't produce the header product" msgstr "No producir producto de cabecera" +#. module: custom_mrp_descarga +#: model:ir.model.fields,field_description:custom_mrp_descarga.field_stock_move_line__qty_done +msgid "Done" +msgstr "Hecho" + #. module: custom_mrp_descarga #: model_terms:ir.ui.view,arch_db:custom_mrp_descarga.stock_move_line_view_search msgid "Done bigger than 0" @@ -371,6 +377,7 @@ msgstr "Galllinas" #: model:ir.model.fields,field_description:custom_mrp_descarga.field_account_analytic_line__id #: model:ir.model.fields,field_description:custom_mrp_descarga.field_mrp_bom__id #: model:ir.model.fields,field_description:custom_mrp_descarga.field_mrp_production__id +#: model:ir.model.fields,field_description:custom_mrp_descarga.field_mrp_workorder__id #: model:ir.model.fields,field_description:custom_mrp_descarga.field_product_template__id #: model:ir.model.fields,field_description:custom_mrp_descarga.field_project_task__id #: model:ir.model.fields,field_description:custom_mrp_descarga.field_report_mrp_production_quartering_summary_xlsx__id @@ -402,6 +409,11 @@ msgstr "Incubadora" msgid "Input Products" msgstr "Productos de entrada" +#. module: custom_mrp_descarga +#: model:ir.model.fields,field_description:custom_mrp_descarga.field_mrp_production__speed_consume_unit +msgid "Input Unit/Hour" +msgstr "Unidades entradas/hora" + #. module: custom_mrp_descarga #: model_terms:ir.ui.view,arch_db:custom_mrp_descarga.mrp_bom_form_view #: model_terms:ir.ui.view,arch_db:custom_mrp_descarga.mrp_production_form_view @@ -463,6 +475,7 @@ msgstr "" #: model:ir.model.fields,field_description:custom_mrp_descarga.field_account_analytic_line____last_update #: model:ir.model.fields,field_description:custom_mrp_descarga.field_mrp_bom____last_update #: model:ir.model.fields,field_description:custom_mrp_descarga.field_mrp_production____last_update +#: model:ir.model.fields,field_description:custom_mrp_descarga.field_mrp_workorder____last_update #: model:ir.model.fields,field_description:custom_mrp_descarga.field_product_template____last_update #: model:ir.model.fields,field_description:custom_mrp_descarga.field_project_task____last_update #: model:ir.model.fields,field_description:custom_mrp_descarga.field_report_mrp_production_quartering_summary_xlsx____last_update @@ -630,6 +643,11 @@ msgstr "Rendimiento" msgid "Peso medio" msgstr "" +#. module: custom_mrp_descarga +#: model:ir.model.fields,field_description:custom_mrp_descarga.field_mrp_production__speed_consume_qty +msgid "Produced Kg/Hour" +msgstr "Kg producidos/hora" + #. module: custom_mrp_descarga #: model:ir.model.fields,field_description:custom_mrp_descarga.field_mrp_production__produced_qty msgid "Produced Qty" @@ -854,6 +872,11 @@ msgstr "El lote saliente debe coincidir con alguno de la entrada." msgid "The product of the lot does not match with the product of the line." msgstr "El producto del lote no coincide con el producto de la línea." +#. module: custom_mrp_descarga +#: model:ir.model.fields,field_description:custom_mrp_descarga.field_mrp_production__timesheet_ids +msgid "Timesheet" +msgstr "Tiempos" + #. module: custom_mrp_descarga #: model_terms:ir.ui.view,arch_db:custom_mrp_descarga.view_mrp_production_filter msgid "Today" @@ -885,6 +908,13 @@ msgstr "Total envases" msgid "Total Done" msgstr "Total hecho" +#. module: custom_mrp_descarga +#: model:ir.model.fields,field_description:custom_mrp_descarga.field_mrp_production__total_duration +#: model:ir.model.fields,field_description:custom_mrp_descarga.field_mrp_workorder__total_duration +#: model_terms:ir.ui.view,arch_db:custom_mrp_descarga.mrp_production_workorder_tree_editable_view +msgid "Total Duration" +msgstr "Duración total" + #. module: custom_mrp_descarga #: code:addons/custom_mrp_descarga/report/mrp_production_quartering_summary_xlsx.py:0 #: code:addons/custom_mrp_descarga/report/mrp_production_quartering_summary_xlsx.py:0 @@ -985,11 +1015,21 @@ msgstr "Fecha descarga" msgid "Vehicle" msgstr "Vehículo" +#. module: custom_mrp_descarga +#: model:ir.model.fields,field_description:custom_mrp_descarga.field_mrp_workorder__waiting_duration +msgid "Waiting" +msgstr "Espera" + #. module: custom_mrp_descarga #: model:ir.model.fields,field_description:custom_mrp_descarga.field_mrp_production__waiting_time msgid "Waiting Time" msgstr "Tiempo de espera" +#. module: custom_mrp_descarga +#: model:ir.model,name:custom_mrp_descarga.model_mrp_workorder +msgid "Work Order" +msgstr "Orden de trabajo" + #. module: custom_mrp_descarga #: model:ir.ui.menu,name:custom_mrp_descarga.menu_view_workcenter_cost_despiece msgid "Workcenter Cost" diff --git a/custom_mrp_descarga/models/__init__.py b/custom_mrp_descarga/models/__init__.py index 2cf7a437c..d33306693 100644 --- a/custom_mrp_descarga/models/__init__.py +++ b/custom_mrp_descarga/models/__init__.py @@ -8,3 +8,4 @@ from . import stock_move_line from . import mrp_bom from . import stock_inventory_line +from . import mrp_workorder diff --git a/custom_mrp_descarga/models/mrp_production.py b/custom_mrp_descarga/models/mrp_production.py index cb0c22b62..78fcd3959 100644 --- a/custom_mrp_descarga/models/mrp_production.py +++ b/custom_mrp_descarga/models/mrp_production.py @@ -218,6 +218,44 @@ def _default_production_date(self): related="bom_id.recalculate_cost", store=True, ) + total_duration = fields.Float(compute="_compute_total_duration", store=True) + speed_consume_qty = fields.Float( + string="Produced Kg/Hour", compute="_compute_speed_consume_qty", store=True + ) + speed_consume_unit = fields.Float( + string="Input Unit/Hour", + compute="_compute_speed_consume_unit", + store=True, + ) + timesheet_ids = fields.One2many( + comodel_name="account.analytic.line", related="saca_line_id.timesheet_ids" + ) + + @api.depends("total_duration", "total_unit") + def _compute_speed_consume_unit(self): + for production in self: + speed_consume_unit = 0 + if production.total_duration != 0: + speed_consume_unit = ( + production.total_unit / production.total_duration * 60 + ) + production.speed_consume_unit = speed_consume_unit + + @api.depends("total_duration", "produced_qty") + def _compute_speed_consume_qty(self): + for production in self: + speed_produced_qty = 0 + if production.total_duration != 0: + speed_produced_qty = ( + production.produced_qty / production.total_duration * 60 + ) + production.speed_consume_qty = speed_produced_qty + + @api.depends("workorder_ids", "workorder_ids.duration") + def _compute_total_duration(self): + for production in self: + duration = sum(production.workorder_ids.mapped("duration")) + production.total_duration = duration @api.depends("move_line_ids.percentage") def _compute_rto_percentage(self): @@ -269,12 +307,6 @@ def _compute_asphyxiation_units(self): ) line.asphyxiation_units = asphyxiation_units - def _compute_classified_ids(self): - for line in self: - cond = [("production_id", "=", line.id), ("classified", "=", True)] - classified = self.env["account.analytic.line"].search(cond) - line.clasified_ids = [(6, 0, classified.ids)] - @api.depends("produced_qty", "consume_qty") def _compute_qty_difference(self): for production in self: diff --git a/custom_mrp_descarga/models/mrp_workorder.py b/custom_mrp_descarga/models/mrp_workorder.py new file mode 100644 index 000000000..5af87af61 --- /dev/null +++ b/custom_mrp_descarga/models/mrp_workorder.py @@ -0,0 +1,29 @@ +# Copyright 2024 Berezi Amubieta - AvanzOSC +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). +from datetime import timedelta + +from odoo import api, fields, models + + +class MrpWorkorder(models.Model): + _inherit = "mrp.workorder" + + waiting_duration = fields.Float( + string="Waiting", compute="_compute_waiting_duration", store=True + ) + total_duration = fields.Float(compute="_compute_total_duration", store=True) + + @api.depends("duration", "waiting_duration") + def _compute_total_duration(self): + for workorder in self: + workorder.total_duration = workorder.duration + workorder.waiting_duration + + @api.depends("date_start", "date_finished", "duration") + def _compute_waiting_duration(self): + for workorder in self: + waiting = 0 + if workorder.date_start and workorder.date_finished: + dif = workorder.date_finished - workorder.date_start + dif = dif.total_seconds() / timedelta(minutes=1).total_seconds() + waiting = dif - workorder.duration + workorder.waiting_duration = waiting diff --git a/custom_mrp_descarga/models/stock_inventory_line.py b/custom_mrp_descarga/models/stock_inventory_line.py index 6d00867cb..c9c64f5e2 100644 --- a/custom_mrp_descarga/models/stock_inventory_line.py +++ b/custom_mrp_descarga/models/stock_inventory_line.py @@ -28,7 +28,7 @@ def onchange_cost(self): and (c.location_id == self.location_id) and c.picking_id ) - if entry_line: + if entry_line and sum(entry_line.mapped("qty_done")) != 0: dev_line_amount = sum(dev_line.mapped("amount")) or 0 dev_line_qty = sum(dev_line.mapped("qty_done")) or 0 self.cost = (sum(entry_line.mapped("amount")) - dev_line_amount) / ( diff --git a/custom_mrp_descarga/views/mrp_production_view.xml b/custom_mrp_descarga/views/mrp_production_view.xml index 3a8403765..b516d57eb 100644 --- a/custom_mrp_descarga/views/mrp_production_view.xml +++ b/custom_mrp_descarga/views/mrp_production_view.xml @@ -352,8 +352,11 @@ /> + + + 1 @@ -642,6 +645,33 @@ + + + + + + + + + + + + + + diff --git a/custom_mrp_descarga/views/mrp_workorder_view.xml b/custom_mrp_descarga/views/mrp_workorder_view.xml new file mode 100644 index 000000000..93ba864d8 --- /dev/null +++ b/custom_mrp_descarga/views/mrp_workorder_view.xml @@ -0,0 +1,19 @@ + + + + mrp.workorder + + + + Total Duration + + + + + + + +