From 0b753301fd4e4760e6444aecbe4b4cf63771b124 Mon Sep 17 00:00:00 2001 From: plersundi <96430355+plersundi@users.noreply.github.com> Date: Mon, 20 Jun 2022 16:26:54 +0200 Subject: [PATCH 1/3] [ADD] mrp_production_cost: New object mrp production cost. (#174) --- mrp_production_cost/README.rst | 32 ++++ mrp_production_cost/__init__.py | 1 + mrp_production_cost/__manifest__.py | 21 +++ mrp_production_cost/i18n/es.po | 138 ++++++++++++++++++ .../i18n/mrp_production_cost.pot | 138 ++++++++++++++++++ mrp_production_cost/models/__init__.py | 3 + mrp_production_cost/models/mrp_production.py | 70 +++++++++ mrp_production_cost/models/mrp_workorder.py | 29 ++++ mrp_production_cost/models/stock_move.py | 29 ++++ .../views/mrp_production_views.xml | 35 +++++ .../views/mrp_stockmove_views.xml | 19 +++ .../views/mrp_workorder_views.xml | 20 +++ 12 files changed, 535 insertions(+) create mode 100644 mrp_production_cost/README.rst create mode 100644 mrp_production_cost/__init__.py create mode 100644 mrp_production_cost/__manifest__.py create mode 100644 mrp_production_cost/i18n/es.po create mode 100644 mrp_production_cost/i18n/mrp_production_cost.pot create mode 100644 mrp_production_cost/models/__init__.py create mode 100644 mrp_production_cost/models/mrp_production.py create mode 100644 mrp_production_cost/models/mrp_workorder.py create mode 100644 mrp_production_cost/models/stock_move.py create mode 100644 mrp_production_cost/views/mrp_production_views.xml create mode 100644 mrp_production_cost/views/mrp_stockmove_views.xml create mode 100644 mrp_production_cost/views/mrp_workorder_views.xml diff --git a/mrp_production_cost/README.rst b/mrp_production_cost/README.rst new file mode 100644 index 000000000..39b9a95df --- /dev/null +++ b/mrp_production_cost/README.rst @@ -0,0 +1,32 @@ +.. image:: https://img.shields.io/badge/licence-AGPL--3-blue.svg + :target: http://www.gnu.org/licenses/agpl-3.0-standalone.html + :alt: License: AGPL-3 + +=================== +MRP Production Cost +=================== + +Cost related fields in manufacturing orders: + +* In "Components" of a Manufacturing Order +* In "Work Orders" of a Manufacturing Order +* In the Manufacturing Order List + +Bug Tracker +=========== + +Bugs are tracked on `GitHub Issues +`_. In case of trouble, +please check there if your issue has already been reported. If you spotted +it first, help us smash it by providing detailed and welcomed feedback. + +Do not contact contributors directly about support or help with technical issues. + +Credits +======= + +Contributors +------------ + +* Patxi Lersundi +* Ana Juaristi diff --git a/mrp_production_cost/__init__.py b/mrp_production_cost/__init__.py new file mode 100644 index 000000000..0650744f6 --- /dev/null +++ b/mrp_production_cost/__init__.py @@ -0,0 +1 @@ +from . import models diff --git a/mrp_production_cost/__manifest__.py b/mrp_production_cost/__manifest__.py new file mode 100644 index 000000000..3ede196a4 --- /dev/null +++ b/mrp_production_cost/__manifest__.py @@ -0,0 +1,21 @@ +# Copyright 2022 Patxi lersundi +# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html +{ + "name": "MRP Production Cost", + "author": "AvanzOSC", + "website": "https://github.com/avanzosc/mrp-addons", + "category": "MRP", + "license": "AGPL-3", + "version": "14.0.1.0.0", + "depends": [ + "product", + "mrp", + "stock", + ], + "data": [ + "views/mrp_production_views.xml", + "views/mrp_stockmove_views.xml", + "views/mrp_workorder_views.xml", + ], + "installable": True, +} diff --git a/mrp_production_cost/i18n/es.po b/mrp_production_cost/i18n/es.po new file mode 100644 index 000000000..fc8c6a805 --- /dev/null +++ b/mrp_production_cost/i18n/es.po @@ -0,0 +1,138 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * mrp_production_cost +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 14.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2022-06-20 13:26+0000\n" +"PO-Revision-Date: 2022-06-20 13:26+0000\n" +"Last-Translator: \n" +"Language-Team: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: \n" + +#. module: mrp_production_cost +#: model:ir.model.fields,field_description:mrp_production_cost.field_mrp_production__cost_manufacturing_estimated +#: model_terms:ir.ui.view,arch_db:mrp_production_cost.mrp_production_tree_view +msgid "Cost Manufacturing estimated" +msgstr "Coste de Fabricación estimado" + +#. module: mrp_production_cost +#: model:ir.model.fields,field_description:mrp_production_cost.field_mrp_production__cost_manufacturing_real +#: model_terms:ir.ui.view,arch_db:mrp_production_cost.mrp_production_tree_view +msgid "Cost Manufacturing real" +msgstr "Coste de Fabricación real" + +#. module: mrp_production_cost +#: model:ir.model.fields,field_description:mrp_production_cost.field_mrp_production__cost_material_consumed +#: model_terms:ir.ui.view,arch_db:mrp_production_cost.mrp_production_form_view +#: model_terms:ir.ui.view,arch_db:mrp_production_cost.mrp_production_tree_view +msgid "Cost Material consumed" +msgstr "Coste de Material consumido" + +#. module: mrp_production_cost +#: model:ir.model.fields,field_description:mrp_production_cost.field_mrp_production__cost_material_to_consume +#: model_terms:ir.ui.view,arch_db:mrp_production_cost.mrp_production_form_view +#: model_terms:ir.ui.view,arch_db:mrp_production_cost.mrp_production_tree_view +msgid "Cost Material to consume" +msgstr "Coste de Material a consumir" + +#. module: mrp_production_cost +#: model:ir.model.fields,field_description:mrp_production_cost.field_mrp_production__cost_workorder_estimated +#: model_terms:ir.ui.view,arch_db:mrp_production_cost.mrp_production_tree_view +msgid "Cost Workorder estimated" +msgstr "Coste de Orden de trabajo estimado" + +#. module: mrp_production_cost +#: model:ir.model.fields,field_description:mrp_production_cost.field_mrp_production__cost_workorder_real +#: model_terms:ir.ui.view,arch_db:mrp_production_cost.mrp_production_tree_view +msgid "Cost Workorder real" +msgstr "Coste de Orden de trabajo real" + +#. module: mrp_production_cost +#: model:ir.model.fields,field_description:mrp_production_cost.field_mrp_production__display_name +#: model:ir.model.fields,field_description:mrp_production_cost.field_mrp_workorder__display_name +#: model:ir.model.fields,field_description:mrp_production_cost.field_stock_move__display_name +msgid "Display Name" +msgstr "Nombre mostrado" + +#. module: mrp_production_cost +#: model:ir.model.fields,field_description:mrp_production_cost.field_mrp_production__id +#: model:ir.model.fields,field_description:mrp_production_cost.field_mrp_workorder__id +#: model:ir.model.fields,field_description:mrp_production_cost.field_stock_move__id +msgid "ID" +msgstr "" + +#. module: mrp_production_cost +#: model:ir.model.fields,help:mrp_production_cost.field_stock_move__product_standard_cost +msgid "" +"In Standard Price & AVCO: value of the product (automatically computed in AVCO).\n" +" In FIFO: value of the last unit that left the stock (automatically computed).\n" +" Used to value the product when the purchase cost is not known (e.g. inventory adjustment).\n" +" Used to compute margins on sale orders." +msgstr "" + +#. module: mrp_production_cost +#: model:ir.model.fields,field_description:mrp_production_cost.field_mrp_production____last_update +#: model:ir.model.fields,field_description:mrp_production_cost.field_mrp_workorder____last_update +#: model:ir.model.fields,field_description:mrp_production_cost.field_stock_move____last_update +msgid "Last Modified on" +msgstr "Última modificación el" + +#. module: mrp_production_cost +#: model:ir.model.fields,field_description:mrp_production_cost.field_mrp_workorder__machine_hour_cost +msgid "Machine hour cost" +msgstr "Coste hora máquina" + +#. module: mrp_production_cost +#: model:ir.model.fields,field_description:mrp_production_cost.field_stock_move__material_cost_consumed +#: model_terms:ir.ui.view,arch_db:mrp_production_cost.view_move_tree +msgid "Material cost consumed" +msgstr "Coste de Material consumido" + +#. module: mrp_production_cost +#: model:ir.model.fields,field_description:mrp_production_cost.field_stock_move__material_cost_to_consume +#: model_terms:ir.ui.view,arch_db:mrp_production_cost.view_move_tree +msgid "Material cost to consume" +msgstr "Coste de Material a consumir" + +#. module: mrp_production_cost +#: model:ir.model,name:mrp_production_cost.model_mrp_production +msgid "Production Order" +msgstr "Orden de producción" + +#. module: mrp_production_cost +#: model:ir.model.fields,help:mrp_production_cost.field_mrp_workorder__machine_hour_cost +msgid "Specify cost of work center per hour." +msgstr "Especificar coste por hora del centro de trabajo" + +#. module: mrp_production_cost +#: model:ir.model.fields,field_description:mrp_production_cost.field_stock_move__product_standard_cost +msgid "Standard Cost" +msgstr "Coste Estándard" + +#. module: mrp_production_cost +#: model:ir.model,name:mrp_production_cost.model_stock_move +msgid "Stock Move" +msgstr "Movimiento de existencias" + +#. module: mrp_production_cost +#: model:ir.model,name:mrp_production_cost.model_mrp_workorder +msgid "Work Order" +msgstr "Orden de trabajo" + +#. module: mrp_production_cost +#: model:ir.model.fields,field_description:mrp_production_cost.field_mrp_workorder__workorder_cost_estimated +#: model_terms:ir.ui.view,arch_db:mrp_production_cost.mrp_production_workorder_tree_editable_view +msgid "Workorder Cost estimated" +msgstr "Coste de Orden de trabajo estimado" + +#. module: mrp_production_cost +#: model:ir.model.fields,field_description:mrp_production_cost.field_mrp_workorder__workorder_cost_real +#: model_terms:ir.ui.view,arch_db:mrp_production_cost.mrp_production_workorder_tree_editable_view +msgid "Workorder Cost real" +msgstr "Coste de Orden de trabajo real" diff --git a/mrp_production_cost/i18n/mrp_production_cost.pot b/mrp_production_cost/i18n/mrp_production_cost.pot new file mode 100644 index 000000000..452895071 --- /dev/null +++ b/mrp_production_cost/i18n/mrp_production_cost.pot @@ -0,0 +1,138 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * mrp_production_cost +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 14.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2022-06-20 13:26+0000\n" +"PO-Revision-Date: 2022-06-20 13:26+0000\n" +"Last-Translator: \n" +"Language-Team: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: \n" + +#. module: mrp_production_cost +#: model:ir.model.fields,field_description:mrp_production_cost.field_mrp_production__cost_manufacturing_estimated +#: model_terms:ir.ui.view,arch_db:mrp_production_cost.mrp_production_tree_view +msgid "Cost Manufacturing estimated" +msgstr "" + +#. module: mrp_production_cost +#: model:ir.model.fields,field_description:mrp_production_cost.field_mrp_production__cost_manufacturing_real +#: model_terms:ir.ui.view,arch_db:mrp_production_cost.mrp_production_tree_view +msgid "Cost Manufacturing real" +msgstr "" + +#. module: mrp_production_cost +#: model:ir.model.fields,field_description:mrp_production_cost.field_mrp_production__cost_material_consumed +#: model_terms:ir.ui.view,arch_db:mrp_production_cost.mrp_production_form_view +#: model_terms:ir.ui.view,arch_db:mrp_production_cost.mrp_production_tree_view +msgid "Cost Material consumed" +msgstr "" + +#. module: mrp_production_cost +#: model:ir.model.fields,field_description:mrp_production_cost.field_mrp_production__cost_material_to_consume +#: model_terms:ir.ui.view,arch_db:mrp_production_cost.mrp_production_form_view +#: model_terms:ir.ui.view,arch_db:mrp_production_cost.mrp_production_tree_view +msgid "Cost Material to consume" +msgstr "" + +#. module: mrp_production_cost +#: model:ir.model.fields,field_description:mrp_production_cost.field_mrp_production__cost_workorder_estimated +#: model_terms:ir.ui.view,arch_db:mrp_production_cost.mrp_production_tree_view +msgid "Cost Workorder estimated" +msgstr "" + +#. module: mrp_production_cost +#: model:ir.model.fields,field_description:mrp_production_cost.field_mrp_production__cost_workorder_real +#: model_terms:ir.ui.view,arch_db:mrp_production_cost.mrp_production_tree_view +msgid "Cost Workorder real" +msgstr "" + +#. module: mrp_production_cost +#: model:ir.model.fields,field_description:mrp_production_cost.field_mrp_production__display_name +#: model:ir.model.fields,field_description:mrp_production_cost.field_mrp_workorder__display_name +#: model:ir.model.fields,field_description:mrp_production_cost.field_stock_move__display_name +msgid "Display Name" +msgstr "" + +#. module: mrp_production_cost +#: model:ir.model.fields,field_description:mrp_production_cost.field_mrp_production__id +#: model:ir.model.fields,field_description:mrp_production_cost.field_mrp_workorder__id +#: model:ir.model.fields,field_description:mrp_production_cost.field_stock_move__id +msgid "ID" +msgstr "" + +#. module: mrp_production_cost +#: model:ir.model.fields,help:mrp_production_cost.field_stock_move__product_standard_cost +msgid "" +"In Standard Price & AVCO: value of the product (automatically computed in AVCO).\n" +" In FIFO: value of the last unit that left the stock (automatically computed).\n" +" Used to value the product when the purchase cost is not known (e.g. inventory adjustment).\n" +" Used to compute margins on sale orders." +msgstr "" + +#. module: mrp_production_cost +#: model:ir.model.fields,field_description:mrp_production_cost.field_mrp_production____last_update +#: model:ir.model.fields,field_description:mrp_production_cost.field_mrp_workorder____last_update +#: model:ir.model.fields,field_description:mrp_production_cost.field_stock_move____last_update +msgid "Last Modified on" +msgstr "" + +#. module: mrp_production_cost +#: model:ir.model.fields,field_description:mrp_production_cost.field_mrp_workorder__machine_hour_cost +msgid "Machine hour cost" +msgstr "" + +#. module: mrp_production_cost +#: model:ir.model.fields,field_description:mrp_production_cost.field_stock_move__material_cost_consumed +#: model_terms:ir.ui.view,arch_db:mrp_production_cost.view_move_tree +msgid "Material cost consumed" +msgstr "" + +#. module: mrp_production_cost +#: model:ir.model.fields,field_description:mrp_production_cost.field_stock_move__material_cost_to_consume +#: model_terms:ir.ui.view,arch_db:mrp_production_cost.view_move_tree +msgid "Material cost to consume" +msgstr "" + +#. module: mrp_production_cost +#: model:ir.model,name:mrp_production_cost.model_mrp_production +msgid "Production Order" +msgstr "" + +#. module: mrp_production_cost +#: model:ir.model.fields,help:mrp_production_cost.field_mrp_workorder__machine_hour_cost +msgid "Specify cost of work center per hour." +msgstr "" + +#. module: mrp_production_cost +#: model:ir.model.fields,field_description:mrp_production_cost.field_stock_move__product_standard_cost +msgid "Standard Cost" +msgstr "" + +#. module: mrp_production_cost +#: model:ir.model,name:mrp_production_cost.model_stock_move +msgid "Stock Move" +msgstr "" + +#. module: mrp_production_cost +#: model:ir.model,name:mrp_production_cost.model_mrp_workorder +msgid "Work Order" +msgstr "" + +#. module: mrp_production_cost +#: model:ir.model.fields,field_description:mrp_production_cost.field_mrp_workorder__workorder_cost_estimated +#: model_terms:ir.ui.view,arch_db:mrp_production_cost.mrp_production_workorder_tree_editable_view +msgid "Workorder Cost estimated" +msgstr "" + +#. module: mrp_production_cost +#: model:ir.model.fields,field_description:mrp_production_cost.field_mrp_workorder__workorder_cost_real +#: model_terms:ir.ui.view,arch_db:mrp_production_cost.mrp_production_workorder_tree_editable_view +msgid "Workorder Cost real" +msgstr "" diff --git a/mrp_production_cost/models/__init__.py b/mrp_production_cost/models/__init__.py new file mode 100644 index 000000000..cc4d27c9c --- /dev/null +++ b/mrp_production_cost/models/__init__.py @@ -0,0 +1,3 @@ +from . import mrp_production +from . import stock_move +from . import mrp_workorder diff --git a/mrp_production_cost/models/mrp_production.py b/mrp_production_cost/models/mrp_production.py new file mode 100644 index 000000000..970ae7d9e --- /dev/null +++ b/mrp_production_cost/models/mrp_production.py @@ -0,0 +1,70 @@ +# Copyright 2022 Patxi Lersundi +# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html +from odoo import api, fields, models + + +class MrpProduction(models.Model): + _inherit = "mrp.production" + + # Material costs + cost_material_to_consume = fields.Float( + string="Cost Material to consume", copy=False, store=True, + compute="_compute_cost_material_to_consume") + cost_material_consumed = fields.Float( + string="Cost Material consumed", copy=False, store=True, + compute="_compute_cost_material_consumed") + # Workorder costs + cost_workorder_estimated = fields.Float( + string="Cost Workorder estimated", copy=False, store=True, + compute="_compute_cost_workorder_estimated") + cost_workorder_real = fields.Float( + string="Cost Workorder real", copy=False, store=True, + compute='_compute_cost_workorder_real') + # Manufacturing costs + cost_manufacturing_estimated = fields.Float( + string="Cost Manufacturing estimated", copy=False, store=True, + compute='_compute_cost_manufacturing_estimated') + cost_manufacturing_real = fields.Float( + string="Cost Manufacturing real", copy=False, store=True, + compute='_compute_cost_manufacturing_real') + + @api.depends("move_raw_ids.material_cost_to_consume") + def _compute_cost_material_to_consume(self): + for production in self: + production.cost_material_to_consume = sum( + production.move_raw_ids.mapped("material_cost_to_consume") + ) + + @api.depends("move_raw_ids.material_cost_consumed") + def _compute_cost_material_consumed(self): + for production in self: + production.cost_material_consumed = sum( + production.move_raw_ids.mapped("material_cost_consumed") + ) + + @api.depends("workorder_ids.workorder_cost_estimated") + def _compute_cost_workorder_estimated(self): + for production in self: + production.cost_workorder_estimated = sum( + production.workorder_ids.mapped("workorder_cost_estimated") + ) + + @api.depends("workorder_ids.workorder_cost_real") + def _compute_cost_workorder_real(self): + for production in self: + production.cost_workorder_real = ( + sum(production.workorder_ids.mapped("workorder_cost_real"))) + + @api.depends("cost_material_to_consume", "cost_workorder_estimated") + def _compute_cost_manufacturing_estimated(self): + for production in self: + production.cost_manufacturing_estimated = ( + production.cost_material_to_consume + + production.cost_workorder_estimated) + + @api.depends("cost_material_consumed", "cost_workorder_real") + def _compute_cost_manufacturing_real(self): + for production in self: + production.cost_manufacturing_real = ( + production.cost_material_consumed + + production.cost_workorder_real) diff --git a/mrp_production_cost/models/mrp_workorder.py b/mrp_production_cost/models/mrp_workorder.py new file mode 100644 index 000000000..6a28daa76 --- /dev/null +++ b/mrp_production_cost/models/mrp_workorder.py @@ -0,0 +1,29 @@ +# Copyright 2022 Patxi Lersundi +# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html +from odoo import api, fields, models + + +class MrpWorkorder(models.Model): + _inherit = "mrp.workorder" + + machine_hour_cost = fields.Float( + string="Machine hour cost", readonly=True, store=True, copy=False, + related="workcenter_id.costs_hour") + workorder_cost_estimated = fields.Float( + string="Workorder Cost estimated", copy=False, store=True, + compute='_compute_workorder_cost_estimated') + workorder_cost_real = fields.Float( + string="Workorder Cost real", copy=False, store=True, + compute='_compute_workorder_cost_real') + + @api.depends('duration_expected', 'machine_hour_cost') + def _compute_workorder_cost_estimated(self): + for order in self: + order.workorder_cost_estimated = ( + order.machine_hour_cost * order.duration_expected) + + @api.depends('duration', 'machine_hour_cost') + def _compute_workorder_cost_real(self): + for order in self: + order.workorder_cost_real = ( + order.machine_hour_cost * order.duration) diff --git a/mrp_production_cost/models/stock_move.py b/mrp_production_cost/models/stock_move.py new file mode 100644 index 000000000..eed96c972 --- /dev/null +++ b/mrp_production_cost/models/stock_move.py @@ -0,0 +1,29 @@ +# Copyright 2022 Patxi Lersundi +# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html +from odoo import api, models, fields + + +class StockMove(models.Model): + _inherit = "stock.move" + + product_standard_cost = fields.Float( + string="Standard Cost", readonly=True, store=True, copy=False, + related='product_id.standard_price') + material_cost_to_consume = fields.Float( + string="Material cost to consume", store=True, copy=False, + compute='_compute_material_cost_to_consume') + material_cost_consumed = fields.Float( + string="Material cost consumed", store=True, copy=False, + compute='_compute_material_cost_consumed') + + @api.depends('product_standard_cost', 'product_uom_qty') + def _compute_material_cost_to_consume(self): + for move in self: + move.material_cost_to_consume = ( + move.product_standard_cost * move.product_uom_qty) + + @api.depends('product_standard_cost', 'quantity_done') + def _compute_material_cost_consumed(self): + for move in self: + move.material_cost_consumed = ( + move.product_standard_cost * move.quantity_done) diff --git a/mrp_production_cost/views/mrp_production_views.xml b/mrp_production_cost/views/mrp_production_views.xml new file mode 100644 index 000000000..598004beb --- /dev/null +++ b/mrp_production_cost/views/mrp_production_views.xml @@ -0,0 +1,35 @@ + + + + mrp.production + + + + + + + + + Cost Material to consume + + + Cost Material consumed + + + + + + mrp.production + + + + + + + + + + + + + diff --git a/mrp_production_cost/views/mrp_stockmove_views.xml b/mrp_production_cost/views/mrp_stockmove_views.xml new file mode 100644 index 000000000..b8cb36a57 --- /dev/null +++ b/mrp_production_cost/views/mrp_stockmove_views.xml @@ -0,0 +1,19 @@ + + + + stock.move + + + + + + + + Material cost to consume + + + Material cost consumed + + + + diff --git a/mrp_production_cost/views/mrp_workorder_views.xml b/mrp_production_cost/views/mrp_workorder_views.xml new file mode 100644 index 000000000..67669fa75 --- /dev/null +++ b/mrp_production_cost/views/mrp_workorder_views.xml @@ -0,0 +1,20 @@ + + + + mrp.workorder + + + + + + + + + Workorder Cost estimated + + + Workorder Cost real + + + + From 35836079c88ea5b4c2331f32220a11444c2e33e6 Mon Sep 17 00:00:00 2001 From: Oihane Crucelaegui Date: Thu, 27 Jun 2024 14:44:38 +0200 Subject: [PATCH 2/3] [IMP] mrp_production_cost: pre-commit stuff --- mrp_production_cost/models/mrp_production.py | 56 +++++++++++++------ mrp_production_cost/models/mrp_workorder.py | 32 +++++++---- mrp_production_cost/models/stock_move.py | 34 +++++++---- .../views/mrp_production_views.xml | 22 +++++--- .../views/mrp_stockmove_views.xml | 4 +- .../views/mrp_workorder_views.xml | 11 ++-- 6 files changed, 105 insertions(+), 54 deletions(-) diff --git a/mrp_production_cost/models/mrp_production.py b/mrp_production_cost/models/mrp_production.py index 970ae7d9e..6a88a8c7d 100644 --- a/mrp_production_cost/models/mrp_production.py +++ b/mrp_production_cost/models/mrp_production.py @@ -8,25 +8,43 @@ class MrpProduction(models.Model): # Material costs cost_material_to_consume = fields.Float( - string="Cost Material to consume", copy=False, store=True, - compute="_compute_cost_material_to_consume") + string="Cost Material to consume", + copy=False, + store=True, + compute="_compute_cost_material_to_consume", + ) cost_material_consumed = fields.Float( - string="Cost Material consumed", copy=False, store=True, - compute="_compute_cost_material_consumed") + string="Cost Material consumed", + copy=False, + store=True, + compute="_compute_cost_material_consumed", + ) # Workorder costs cost_workorder_estimated = fields.Float( - string="Cost Workorder estimated", copy=False, store=True, - compute="_compute_cost_workorder_estimated") + string="Cost Workorder estimated", + copy=False, + store=True, + compute="_compute_cost_workorder_estimated", + ) cost_workorder_real = fields.Float( - string="Cost Workorder real", copy=False, store=True, - compute='_compute_cost_workorder_real') + string="Cost Workorder real", + copy=False, + store=True, + compute="_compute_cost_workorder_real", + ) # Manufacturing costs cost_manufacturing_estimated = fields.Float( - string="Cost Manufacturing estimated", copy=False, store=True, - compute='_compute_cost_manufacturing_estimated') + string="Cost Manufacturing estimated", + copy=False, + store=True, + compute="_compute_cost_manufacturing_estimated", + ) cost_manufacturing_real = fields.Float( - string="Cost Manufacturing real", copy=False, store=True, - compute='_compute_cost_manufacturing_real') + string="Cost Manufacturing real", + copy=False, + store=True, + compute="_compute_cost_manufacturing_real", + ) @api.depends("move_raw_ids.material_cost_to_consume") def _compute_cost_material_to_consume(self): @@ -52,19 +70,21 @@ def _compute_cost_workorder_estimated(self): @api.depends("workorder_ids.workorder_cost_real") def _compute_cost_workorder_real(self): for production in self: - production.cost_workorder_real = ( - sum(production.workorder_ids.mapped("workorder_cost_real"))) + production.cost_workorder_real = sum( + production.workorder_ids.mapped("workorder_cost_real") + ) @api.depends("cost_material_to_consume", "cost_workorder_estimated") def _compute_cost_manufacturing_estimated(self): for production in self: production.cost_manufacturing_estimated = ( - production.cost_material_to_consume + - production.cost_workorder_estimated) + production.cost_material_to_consume + + production.cost_workorder_estimated + ) @api.depends("cost_material_consumed", "cost_workorder_real") def _compute_cost_manufacturing_real(self): for production in self: production.cost_manufacturing_real = ( - production.cost_material_consumed + - production.cost_workorder_real) + production.cost_material_consumed + production.cost_workorder_real + ) diff --git a/mrp_production_cost/models/mrp_workorder.py b/mrp_production_cost/models/mrp_workorder.py index 6a28daa76..34f872119 100644 --- a/mrp_production_cost/models/mrp_workorder.py +++ b/mrp_production_cost/models/mrp_workorder.py @@ -7,23 +7,33 @@ class MrpWorkorder(models.Model): _inherit = "mrp.workorder" machine_hour_cost = fields.Float( - string="Machine hour cost", readonly=True, store=True, copy=False, - related="workcenter_id.costs_hour") + string="Machine hour cost", + readonly=True, + store=True, + copy=False, + related="workcenter_id.costs_hour", + ) workorder_cost_estimated = fields.Float( - string="Workorder Cost estimated", copy=False, store=True, - compute='_compute_workorder_cost_estimated') + string="Workorder Cost estimated", + copy=False, + store=True, + compute="_compute_workorder_cost_estimated", + ) workorder_cost_real = fields.Float( - string="Workorder Cost real", copy=False, store=True, - compute='_compute_workorder_cost_real') + string="Workorder Cost real", + copy=False, + store=True, + compute="_compute_workorder_cost_real", + ) - @api.depends('duration_expected', 'machine_hour_cost') + @api.depends("duration_expected", "machine_hour_cost") def _compute_workorder_cost_estimated(self): for order in self: order.workorder_cost_estimated = ( - order.machine_hour_cost * order.duration_expected) + order.machine_hour_cost * order.duration_expected + ) - @api.depends('duration', 'machine_hour_cost') + @api.depends("duration", "machine_hour_cost") def _compute_workorder_cost_real(self): for order in self: - order.workorder_cost_real = ( - order.machine_hour_cost * order.duration) + order.workorder_cost_real = order.machine_hour_cost * order.duration diff --git a/mrp_production_cost/models/stock_move.py b/mrp_production_cost/models/stock_move.py index eed96c972..7a0215bb9 100644 --- a/mrp_production_cost/models/stock_move.py +++ b/mrp_production_cost/models/stock_move.py @@ -1,29 +1,41 @@ # Copyright 2022 Patxi Lersundi # License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html -from odoo import api, models, fields +from odoo import api, fields, models class StockMove(models.Model): _inherit = "stock.move" product_standard_cost = fields.Float( - string="Standard Cost", readonly=True, store=True, copy=False, - related='product_id.standard_price') + string="Standard Cost", + readonly=True, + store=True, + copy=False, + related="product_id.standard_price", + ) material_cost_to_consume = fields.Float( - string="Material cost to consume", store=True, copy=False, - compute='_compute_material_cost_to_consume') + string="Material cost to consume", + store=True, + copy=False, + compute="_compute_material_cost_to_consume", + ) material_cost_consumed = fields.Float( - string="Material cost consumed", store=True, copy=False, - compute='_compute_material_cost_consumed') + string="Material cost consumed", + store=True, + copy=False, + compute="_compute_material_cost_consumed", + ) - @api.depends('product_standard_cost', 'product_uom_qty') + @api.depends("product_standard_cost", "product_uom_qty") def _compute_material_cost_to_consume(self): for move in self: move.material_cost_to_consume = ( - move.product_standard_cost * move.product_uom_qty) + move.product_standard_cost * move.product_uom_qty + ) - @api.depends('product_standard_cost', 'quantity_done') + @api.depends("product_standard_cost", "quantity_done") def _compute_material_cost_consumed(self): for move in self: move.material_cost_consumed = ( - move.product_standard_cost * move.quantity_done) + move.product_standard_cost * move.quantity_done + ) diff --git a/mrp_production_cost/views/mrp_production_views.xml b/mrp_production_cost/views/mrp_production_views.xml index 598004beb..5672e7caa 100644 --- a/mrp_production_cost/views/mrp_production_views.xml +++ b/mrp_production_cost/views/mrp_production_views.xml @@ -1,13 +1,16 @@ - + mrp.production - + - - - - + + + + Cost Material to consume @@ -22,12 +25,15 @@ mrp.production - + - + diff --git a/mrp_production_cost/views/mrp_stockmove_views.xml b/mrp_production_cost/views/mrp_stockmove_views.xml index b8cb36a57..d98a929a8 100644 --- a/mrp_production_cost/views/mrp_stockmove_views.xml +++ b/mrp_production_cost/views/mrp_stockmove_views.xml @@ -5,8 +5,8 @@ - - + + Material cost to consume diff --git a/mrp_production_cost/views/mrp_workorder_views.xml b/mrp_production_cost/views/mrp_workorder_views.xml index 67669fa75..e12435fb0 100644 --- a/mrp_production_cost/views/mrp_workorder_views.xml +++ b/mrp_production_cost/views/mrp_workorder_views.xml @@ -2,12 +2,15 @@ mrp.workorder - + - - - + + + Workorder Cost estimated From fbc4466cc006b2e446fed6e5ba3969eec5c86ad8 Mon Sep 17 00:00:00 2001 From: Oihane Crucelaegui Date: Fri, 28 Jun 2024 15:38:57 +0200 Subject: [PATCH 3/3] [MIG] mrp_production_cost: Migration to 16.0 --- mrp_production_cost/README.rst | 6 +- mrp_production_cost/__manifest__.py | 4 +- mrp_production_cost/i18n/es.po | 129 ++++++------------ .../i18n/mrp_production_cost.pot | 107 +++++---------- mrp_production_cost/models/mrp_production.py | 20 +-- mrp_production_cost/models/mrp_workorder.py | 21 +-- mrp_production_cost/models/stock_move.py | 23 +--- .../views/mrp_production_views.xml | 51 ++++--- .../views/mrp_stockmove_views.xml | 18 +-- .../views/mrp_workorder_views.xml | 20 +-- .../odoo/addons/mrp_production_cost | 1 + setup/mrp_production_cost/setup.py | 6 + 12 files changed, 160 insertions(+), 246 deletions(-) create mode 120000 setup/mrp_production_cost/odoo/addons/mrp_production_cost create mode 100644 setup/mrp_production_cost/setup.py diff --git a/mrp_production_cost/README.rst b/mrp_production_cost/README.rst index 39b9a95df..b9176a2fd 100644 --- a/mrp_production_cost/README.rst +++ b/mrp_production_cost/README.rst @@ -6,11 +6,9 @@ MRP Production Cost =================== -Cost related fields in manufacturing orders: +This module makes an estimation of the cost of a Manufacturing Order. -* In "Components" of a Manufacturing Order -* In "Work Orders" of a Manufacturing Order -* In the Manufacturing Order List +The user can visualise the cost data in the component lines, in the work orders and in the list of production orders. Bug Tracker =========== diff --git a/mrp_production_cost/__manifest__.py b/mrp_production_cost/__manifest__.py index 3ede196a4..c2b114a87 100644 --- a/mrp_production_cost/__manifest__.py +++ b/mrp_production_cost/__manifest__.py @@ -4,9 +4,9 @@ "name": "MRP Production Cost", "author": "AvanzOSC", "website": "https://github.com/avanzosc/mrp-addons", - "category": "MRP", + "category": "Manufacturing/Manufacturing", "license": "AGPL-3", - "version": "14.0.1.0.0", + "version": "16.0.1.0.0", "depends": [ "product", "mrp", diff --git a/mrp_production_cost/i18n/es.po b/mrp_production_cost/i18n/es.po index fc8c6a805..fb6c905ff 100644 --- a/mrp_production_cost/i18n/es.po +++ b/mrp_production_cost/i18n/es.po @@ -4,10 +4,10 @@ # msgid "" msgstr "" -"Project-Id-Version: Odoo Server 14.0\n" +"Project-Id-Version: Odoo Server 16.0\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2022-06-20 13:26+0000\n" -"PO-Revision-Date: 2022-06-20 13:26+0000\n" +"POT-Creation-Date: 2024-07-16 08:40+0000\n" +"PO-Revision-Date: 2024-07-16 08:40+0000\n" "Last-Translator: \n" "Language-Team: \n" "MIME-Version: 1.0\n" @@ -16,104 +16,71 @@ msgstr "" "Plural-Forms: \n" #. module: mrp_production_cost -#: model:ir.model.fields,field_description:mrp_production_cost.field_mrp_production__cost_manufacturing_estimated -#: model_terms:ir.ui.view,arch_db:mrp_production_cost.mrp_production_tree_view -msgid "Cost Manufacturing estimated" -msgstr "Coste de Fabricación estimado" +#: model:ir.model.fields,field_description:mrp_production_cost.field_mrp_workorder__workorder_cost_estimated +#: model:ir.model.fields,field_description:mrp_production_cost.field_stock_move__material_cost_to_consume +msgid "Estimated Cost" +msgstr "Coste estimado" #. module: mrp_production_cost -#: model:ir.model.fields,field_description:mrp_production_cost.field_mrp_production__cost_manufacturing_real -#: model_terms:ir.ui.view,arch_db:mrp_production_cost.mrp_production_tree_view -msgid "Cost Manufacturing real" -msgstr "Coste de Fabricación real" +#: model:ir.model.fields,field_description:mrp_production_cost.field_mrp_production__cost_manufacturing_estimated +msgid "Estimated Manufacturing Cost" +msgstr "Coste de fabricación estimado" #. module: mrp_production_cost -#: model:ir.model.fields,field_description:mrp_production_cost.field_mrp_production__cost_material_consumed -#: model_terms:ir.ui.view,arch_db:mrp_production_cost.mrp_production_form_view +#: model:ir.model.fields,field_description:mrp_production_cost.field_mrp_production__cost_material_to_consume #: model_terms:ir.ui.view,arch_db:mrp_production_cost.mrp_production_tree_view -msgid "Cost Material consumed" -msgstr "Coste de Material consumido" +msgid "Estimated Material Cost" +msgstr "Coste de material estimado" #. module: mrp_production_cost -#: model:ir.model.fields,field_description:mrp_production_cost.field_mrp_production__cost_material_to_consume #: model_terms:ir.ui.view,arch_db:mrp_production_cost.mrp_production_form_view #: model_terms:ir.ui.view,arch_db:mrp_production_cost.mrp_production_tree_view -msgid "Cost Material to consume" -msgstr "Coste de Material a consumir" +#: model_terms:ir.ui.view,arch_db:mrp_production_cost.mrp_production_workorder_tree_editable_view +#: model_terms:ir.ui.view,arch_db:mrp_production_cost.view_move_tree +msgid "Estimated Total Cost" +msgstr "Coste total estimado" #. module: mrp_production_cost #: model:ir.model.fields,field_description:mrp_production_cost.field_mrp_production__cost_workorder_estimated #: model_terms:ir.ui.view,arch_db:mrp_production_cost.mrp_production_tree_view -msgid "Cost Workorder estimated" -msgstr "Coste de Orden de trabajo estimado" - -#. module: mrp_production_cost -#: model:ir.model.fields,field_description:mrp_production_cost.field_mrp_production__cost_workorder_real -#: model_terms:ir.ui.view,arch_db:mrp_production_cost.mrp_production_tree_view -msgid "Cost Workorder real" -msgstr "Coste de Orden de trabajo real" - -#. module: mrp_production_cost -#: model:ir.model.fields,field_description:mrp_production_cost.field_mrp_production__display_name -#: model:ir.model.fields,field_description:mrp_production_cost.field_mrp_workorder__display_name -#: model:ir.model.fields,field_description:mrp_production_cost.field_stock_move__display_name -msgid "Display Name" -msgstr "Nombre mostrado" - -#. module: mrp_production_cost -#: model:ir.model.fields,field_description:mrp_production_cost.field_mrp_production__id -#: model:ir.model.fields,field_description:mrp_production_cost.field_mrp_workorder__id -#: model:ir.model.fields,field_description:mrp_production_cost.field_stock_move__id -msgid "ID" -msgstr "" - -#. module: mrp_production_cost -#: model:ir.model.fields,help:mrp_production_cost.field_stock_move__product_standard_cost -msgid "" -"In Standard Price & AVCO: value of the product (automatically computed in AVCO).\n" -" In FIFO: value of the last unit that left the stock (automatically computed).\n" -" Used to value the product when the purchase cost is not known (e.g. inventory adjustment).\n" -" Used to compute margins on sale orders." -msgstr "" - -#. module: mrp_production_cost -#: model:ir.model.fields,field_description:mrp_production_cost.field_mrp_production____last_update -#: model:ir.model.fields,field_description:mrp_production_cost.field_mrp_workorder____last_update -#: model:ir.model.fields,field_description:mrp_production_cost.field_stock_move____last_update -msgid "Last Modified on" -msgstr "Última modificación el" +msgid "Estimated Work Cost" +msgstr "Coste de trabajo estimado" #. module: mrp_production_cost -#: model:ir.model.fields,field_description:mrp_production_cost.field_mrp_workorder__machine_hour_cost -msgid "Machine hour cost" -msgstr "Coste hora máquina" +#: model:ir.model,name:mrp_production_cost.model_mrp_production +msgid "Production Order" +msgstr "Orden de producción" #. module: mrp_production_cost +#: model:ir.model.fields,field_description:mrp_production_cost.field_mrp_workorder__workorder_cost_real #: model:ir.model.fields,field_description:mrp_production_cost.field_stock_move__material_cost_consumed -#: model_terms:ir.ui.view,arch_db:mrp_production_cost.view_move_tree -msgid "Material cost consumed" -msgstr "Coste de Material consumido" +msgid "Real Cost" +msgstr "Coste real" #. module: mrp_production_cost -#: model:ir.model.fields,field_description:mrp_production_cost.field_stock_move__material_cost_to_consume -#: model_terms:ir.ui.view,arch_db:mrp_production_cost.view_move_tree -msgid "Material cost to consume" -msgstr "Coste de Material a consumir" +#: model:ir.model.fields,field_description:mrp_production_cost.field_mrp_production__cost_manufacturing_real +msgid "Real Manufacturing Cost" +msgstr "Coste de fabricación real" #. module: mrp_production_cost -#: model:ir.model,name:mrp_production_cost.model_mrp_production -msgid "Production Order" -msgstr "Orden de producción" +#: model:ir.model.fields,field_description:mrp_production_cost.field_mrp_production__cost_material_consumed +#: model_terms:ir.ui.view,arch_db:mrp_production_cost.mrp_production_tree_view +msgid "Real Material Cost" +msgstr "Coste de material real" #. module: mrp_production_cost -#: model:ir.model.fields,help:mrp_production_cost.field_mrp_workorder__machine_hour_cost -msgid "Specify cost of work center per hour." -msgstr "Especificar coste por hora del centro de trabajo" +#: model_terms:ir.ui.view,arch_db:mrp_production_cost.mrp_production_form_view +#: model_terms:ir.ui.view,arch_db:mrp_production_cost.mrp_production_tree_view +#: model_terms:ir.ui.view,arch_db:mrp_production_cost.mrp_production_workorder_tree_editable_view +#: model_terms:ir.ui.view,arch_db:mrp_production_cost.view_move_tree +msgid "Real Total Cost" +msgstr "Coste real total" #. module: mrp_production_cost -#: model:ir.model.fields,field_description:mrp_production_cost.field_stock_move__product_standard_cost -msgid "Standard Cost" -msgstr "Coste Estándard" +#: model:ir.model.fields,field_description:mrp_production_cost.field_mrp_production__cost_workorder_real +#: model_terms:ir.ui.view,arch_db:mrp_production_cost.mrp_production_tree_view +msgid "Real Work Cost" +msgstr "Coste de trabajo real" #. module: mrp_production_cost #: model:ir.model,name:mrp_production_cost.model_stock_move @@ -124,15 +91,3 @@ msgstr "Movimiento de existencias" #: model:ir.model,name:mrp_production_cost.model_mrp_workorder msgid "Work Order" msgstr "Orden de trabajo" - -#. module: mrp_production_cost -#: model:ir.model.fields,field_description:mrp_production_cost.field_mrp_workorder__workorder_cost_estimated -#: model_terms:ir.ui.view,arch_db:mrp_production_cost.mrp_production_workorder_tree_editable_view -msgid "Workorder Cost estimated" -msgstr "Coste de Orden de trabajo estimado" - -#. module: mrp_production_cost -#: model:ir.model.fields,field_description:mrp_production_cost.field_mrp_workorder__workorder_cost_real -#: model_terms:ir.ui.view,arch_db:mrp_production_cost.mrp_production_workorder_tree_editable_view -msgid "Workorder Cost real" -msgstr "Coste de Orden de trabajo real" diff --git a/mrp_production_cost/i18n/mrp_production_cost.pot b/mrp_production_cost/i18n/mrp_production_cost.pot index 452895071..e81077937 100644 --- a/mrp_production_cost/i18n/mrp_production_cost.pot +++ b/mrp_production_cost/i18n/mrp_production_cost.pot @@ -4,10 +4,10 @@ # msgid "" msgstr "" -"Project-Id-Version: Odoo Server 14.0\n" +"Project-Id-Version: Odoo Server 16.0\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2022-06-20 13:26+0000\n" -"PO-Revision-Date: 2022-06-20 13:26+0000\n" +"POT-Creation-Date: 2024-07-16 08:40+0000\n" +"PO-Revision-Date: 2024-07-16 08:40+0000\n" "Last-Translator: \n" "Language-Team: \n" "MIME-Version: 1.0\n" @@ -16,103 +16,70 @@ msgstr "" "Plural-Forms: \n" #. module: mrp_production_cost -#: model:ir.model.fields,field_description:mrp_production_cost.field_mrp_production__cost_manufacturing_estimated -#: model_terms:ir.ui.view,arch_db:mrp_production_cost.mrp_production_tree_view -msgid "Cost Manufacturing estimated" +#: model:ir.model.fields,field_description:mrp_production_cost.field_mrp_workorder__workorder_cost_estimated +#: model:ir.model.fields,field_description:mrp_production_cost.field_stock_move__material_cost_to_consume +msgid "Estimated Cost" msgstr "" #. module: mrp_production_cost -#: model:ir.model.fields,field_description:mrp_production_cost.field_mrp_production__cost_manufacturing_real -#: model_terms:ir.ui.view,arch_db:mrp_production_cost.mrp_production_tree_view -msgid "Cost Manufacturing real" +#: model:ir.model.fields,field_description:mrp_production_cost.field_mrp_production__cost_manufacturing_estimated +msgid "Estimated Manufacturing Cost" msgstr "" #. module: mrp_production_cost -#: model:ir.model.fields,field_description:mrp_production_cost.field_mrp_production__cost_material_consumed -#: model_terms:ir.ui.view,arch_db:mrp_production_cost.mrp_production_form_view +#: model:ir.model.fields,field_description:mrp_production_cost.field_mrp_production__cost_material_to_consume #: model_terms:ir.ui.view,arch_db:mrp_production_cost.mrp_production_tree_view -msgid "Cost Material consumed" +msgid "Estimated Material Cost" msgstr "" #. module: mrp_production_cost -#: model:ir.model.fields,field_description:mrp_production_cost.field_mrp_production__cost_material_to_consume #: model_terms:ir.ui.view,arch_db:mrp_production_cost.mrp_production_form_view #: model_terms:ir.ui.view,arch_db:mrp_production_cost.mrp_production_tree_view -msgid "Cost Material to consume" +#: model_terms:ir.ui.view,arch_db:mrp_production_cost.mrp_production_workorder_tree_editable_view +#: model_terms:ir.ui.view,arch_db:mrp_production_cost.view_move_tree +msgid "Estimated Total Cost" msgstr "" #. module: mrp_production_cost #: model:ir.model.fields,field_description:mrp_production_cost.field_mrp_production__cost_workorder_estimated #: model_terms:ir.ui.view,arch_db:mrp_production_cost.mrp_production_tree_view -msgid "Cost Workorder estimated" -msgstr "" - -#. module: mrp_production_cost -#: model:ir.model.fields,field_description:mrp_production_cost.field_mrp_production__cost_workorder_real -#: model_terms:ir.ui.view,arch_db:mrp_production_cost.mrp_production_tree_view -msgid "Cost Workorder real" -msgstr "" - -#. module: mrp_production_cost -#: model:ir.model.fields,field_description:mrp_production_cost.field_mrp_production__display_name -#: model:ir.model.fields,field_description:mrp_production_cost.field_mrp_workorder__display_name -#: model:ir.model.fields,field_description:mrp_production_cost.field_stock_move__display_name -msgid "Display Name" -msgstr "" - -#. module: mrp_production_cost -#: model:ir.model.fields,field_description:mrp_production_cost.field_mrp_production__id -#: model:ir.model.fields,field_description:mrp_production_cost.field_mrp_workorder__id -#: model:ir.model.fields,field_description:mrp_production_cost.field_stock_move__id -msgid "ID" -msgstr "" - -#. module: mrp_production_cost -#: model:ir.model.fields,help:mrp_production_cost.field_stock_move__product_standard_cost -msgid "" -"In Standard Price & AVCO: value of the product (automatically computed in AVCO).\n" -" In FIFO: value of the last unit that left the stock (automatically computed).\n" -" Used to value the product when the purchase cost is not known (e.g. inventory adjustment).\n" -" Used to compute margins on sale orders." -msgstr "" - -#. module: mrp_production_cost -#: model:ir.model.fields,field_description:mrp_production_cost.field_mrp_production____last_update -#: model:ir.model.fields,field_description:mrp_production_cost.field_mrp_workorder____last_update -#: model:ir.model.fields,field_description:mrp_production_cost.field_stock_move____last_update -msgid "Last Modified on" +msgid "Estimated Work Cost" msgstr "" #. module: mrp_production_cost -#: model:ir.model.fields,field_description:mrp_production_cost.field_mrp_workorder__machine_hour_cost -msgid "Machine hour cost" +#: model:ir.model,name:mrp_production_cost.model_mrp_production +msgid "Production Order" msgstr "" #. module: mrp_production_cost +#: model:ir.model.fields,field_description:mrp_production_cost.field_mrp_workorder__workorder_cost_real #: model:ir.model.fields,field_description:mrp_production_cost.field_stock_move__material_cost_consumed -#: model_terms:ir.ui.view,arch_db:mrp_production_cost.view_move_tree -msgid "Material cost consumed" +msgid "Real Cost" msgstr "" #. module: mrp_production_cost -#: model:ir.model.fields,field_description:mrp_production_cost.field_stock_move__material_cost_to_consume -#: model_terms:ir.ui.view,arch_db:mrp_production_cost.view_move_tree -msgid "Material cost to consume" +#: model:ir.model.fields,field_description:mrp_production_cost.field_mrp_production__cost_manufacturing_real +msgid "Real Manufacturing Cost" msgstr "" #. module: mrp_production_cost -#: model:ir.model,name:mrp_production_cost.model_mrp_production -msgid "Production Order" +#: model:ir.model.fields,field_description:mrp_production_cost.field_mrp_production__cost_material_consumed +#: model_terms:ir.ui.view,arch_db:mrp_production_cost.mrp_production_tree_view +msgid "Real Material Cost" msgstr "" #. module: mrp_production_cost -#: model:ir.model.fields,help:mrp_production_cost.field_mrp_workorder__machine_hour_cost -msgid "Specify cost of work center per hour." +#: model_terms:ir.ui.view,arch_db:mrp_production_cost.mrp_production_form_view +#: model_terms:ir.ui.view,arch_db:mrp_production_cost.mrp_production_tree_view +#: model_terms:ir.ui.view,arch_db:mrp_production_cost.mrp_production_workorder_tree_editable_view +#: model_terms:ir.ui.view,arch_db:mrp_production_cost.view_move_tree +msgid "Real Total Cost" msgstr "" #. module: mrp_production_cost -#: model:ir.model.fields,field_description:mrp_production_cost.field_stock_move__product_standard_cost -msgid "Standard Cost" +#: model:ir.model.fields,field_description:mrp_production_cost.field_mrp_production__cost_workorder_real +#: model_terms:ir.ui.view,arch_db:mrp_production_cost.mrp_production_tree_view +msgid "Real Work Cost" msgstr "" #. module: mrp_production_cost @@ -124,15 +91,3 @@ msgstr "" #: model:ir.model,name:mrp_production_cost.model_mrp_workorder msgid "Work Order" msgstr "" - -#. module: mrp_production_cost -#: model:ir.model.fields,field_description:mrp_production_cost.field_mrp_workorder__workorder_cost_estimated -#: model_terms:ir.ui.view,arch_db:mrp_production_cost.mrp_production_workorder_tree_editable_view -msgid "Workorder Cost estimated" -msgstr "" - -#. module: mrp_production_cost -#: model:ir.model.fields,field_description:mrp_production_cost.field_mrp_workorder__workorder_cost_real -#: model_terms:ir.ui.view,arch_db:mrp_production_cost.mrp_production_workorder_tree_editable_view -msgid "Workorder Cost real" -msgstr "" diff --git a/mrp_production_cost/models/mrp_production.py b/mrp_production_cost/models/mrp_production.py index 6a88a8c7d..cf316c86e 100644 --- a/mrp_production_cost/models/mrp_production.py +++ b/mrp_production_cost/models/mrp_production.py @@ -8,39 +8,39 @@ class MrpProduction(models.Model): # Material costs cost_material_to_consume = fields.Float( - string="Cost Material to consume", + string="Estimated Material Cost", copy=False, store=True, compute="_compute_cost_material_to_consume", ) cost_material_consumed = fields.Float( - string="Cost Material consumed", + string="Real Material Cost", copy=False, store=True, compute="_compute_cost_material_consumed", ) # Workorder costs cost_workorder_estimated = fields.Float( - string="Cost Workorder estimated", + string="Estimated Work Cost", copy=False, store=True, compute="_compute_cost_workorder_estimated", ) cost_workorder_real = fields.Float( - string="Cost Workorder real", + string="Real Work Cost", copy=False, store=True, compute="_compute_cost_workorder_real", ) # Manufacturing costs cost_manufacturing_estimated = fields.Float( - string="Cost Manufacturing estimated", + string="Estimated Manufacturing Cost", copy=False, store=True, compute="_compute_cost_manufacturing_estimated", ) cost_manufacturing_real = fields.Float( - string="Cost Manufacturing real", + string="Real Manufacturing Cost", copy=False, store=True, compute="_compute_cost_manufacturing_real", @@ -50,28 +50,28 @@ class MrpProduction(models.Model): def _compute_cost_material_to_consume(self): for production in self: production.cost_material_to_consume = sum( - production.move_raw_ids.mapped("material_cost_to_consume") + production.mapped("move_raw_ids.material_cost_to_consume") ) @api.depends("move_raw_ids.material_cost_consumed") def _compute_cost_material_consumed(self): for production in self: production.cost_material_consumed = sum( - production.move_raw_ids.mapped("material_cost_consumed") + production.mapped("move_raw_ids.material_cost_consumed") ) @api.depends("workorder_ids.workorder_cost_estimated") def _compute_cost_workorder_estimated(self): for production in self: production.cost_workorder_estimated = sum( - production.workorder_ids.mapped("workorder_cost_estimated") + production.mapped("workorder_ids.workorder_cost_estimated") ) @api.depends("workorder_ids.workorder_cost_real") def _compute_cost_workorder_real(self): for production in self: production.cost_workorder_real = sum( - production.workorder_ids.mapped("workorder_cost_real") + production.mapped("workorder_ids.workorder_cost_real") ) @api.depends("cost_material_to_consume", "cost_workorder_estimated") diff --git a/mrp_production_cost/models/mrp_workorder.py b/mrp_production_cost/models/mrp_workorder.py index 34f872119..aebd1aa23 100644 --- a/mrp_production_cost/models/mrp_workorder.py +++ b/mrp_production_cost/models/mrp_workorder.py @@ -6,34 +6,25 @@ class MrpWorkorder(models.Model): _inherit = "mrp.workorder" - machine_hour_cost = fields.Float( - string="Machine hour cost", - readonly=True, - store=True, - copy=False, - related="workcenter_id.costs_hour", - ) workorder_cost_estimated = fields.Float( - string="Workorder Cost estimated", + string="Estimated Cost", copy=False, store=True, compute="_compute_workorder_cost_estimated", ) workorder_cost_real = fields.Float( - string="Workorder Cost real", + string="Real Cost", copy=False, store=True, compute="_compute_workorder_cost_real", ) - @api.depends("duration_expected", "machine_hour_cost") + @api.depends("duration_expected", "costs_hour") def _compute_workorder_cost_estimated(self): for order in self: - order.workorder_cost_estimated = ( - order.machine_hour_cost * order.duration_expected - ) + order.workorder_cost_estimated = order.costs_hour * order.duration_expected - @api.depends("duration", "machine_hour_cost") + @api.depends("duration", "costs_hour") def _compute_workorder_cost_real(self): for order in self: - order.workorder_cost_real = order.machine_hour_cost * order.duration + order.workorder_cost_real = order.costs_hour * order.duration diff --git a/mrp_production_cost/models/stock_move.py b/mrp_production_cost/models/stock_move.py index 7a0215bb9..41b6c8ef2 100644 --- a/mrp_production_cost/models/stock_move.py +++ b/mrp_production_cost/models/stock_move.py @@ -6,36 +6,25 @@ class StockMove(models.Model): _inherit = "stock.move" - product_standard_cost = fields.Float( - string="Standard Cost", - readonly=True, - store=True, - copy=False, - related="product_id.standard_price", - ) material_cost_to_consume = fields.Float( - string="Material cost to consume", + string="Estimated Cost", store=True, copy=False, compute="_compute_material_cost_to_consume", ) material_cost_consumed = fields.Float( - string="Material cost consumed", + string="Real Cost", store=True, copy=False, compute="_compute_material_cost_consumed", ) - @api.depends("product_standard_cost", "product_uom_qty") + @api.depends("price_unit", "product_uom_qty") def _compute_material_cost_to_consume(self): for move in self: - move.material_cost_to_consume = ( - move.product_standard_cost * move.product_uom_qty - ) + move.material_cost_to_consume = move.price_unit * move.product_uom_qty - @api.depends("product_standard_cost", "quantity_done") + @api.depends("price_unit", "quantity_done") def _compute_material_cost_consumed(self): for move in self: - move.material_cost_consumed = ( - move.product_standard_cost * move.quantity_done - ) + move.material_cost_consumed = move.price_unit * move.quantity_done diff --git a/mrp_production_cost/views/mrp_production_views.xml b/mrp_production_cost/views/mrp_production_views.xml index 5672e7caa..4eb1eefc8 100644 --- a/mrp_production_cost/views/mrp_production_views.xml +++ b/mrp_production_cost/views/mrp_production_views.xml @@ -5,19 +5,21 @@ - - - + + + - - Cost Material to consume - - - Cost Material consumed - @@ -25,16 +27,29 @@ mrp.production - - - - - + + + + - + + diff --git a/mrp_production_cost/views/mrp_stockmove_views.xml b/mrp_production_cost/views/mrp_stockmove_views.xml index d98a929a8..d98ece8b6 100644 --- a/mrp_production_cost/views/mrp_stockmove_views.xml +++ b/mrp_production_cost/views/mrp_stockmove_views.xml @@ -5,15 +5,17 @@ - - + + - - Material cost to consume - - - Material cost consumed - diff --git a/mrp_production_cost/views/mrp_workorder_views.xml b/mrp_production_cost/views/mrp_workorder_views.xml index e12435fb0..cfe012b89 100644 --- a/mrp_production_cost/views/mrp_workorder_views.xml +++ b/mrp_production_cost/views/mrp_workorder_views.xml @@ -8,16 +8,18 @@ /> - - - + + + - - Workorder Cost estimated - - - Workorder Cost real - diff --git a/setup/mrp_production_cost/odoo/addons/mrp_production_cost b/setup/mrp_production_cost/odoo/addons/mrp_production_cost new file mode 120000 index 000000000..163f7ef00 --- /dev/null +++ b/setup/mrp_production_cost/odoo/addons/mrp_production_cost @@ -0,0 +1 @@ +../../../../mrp_production_cost \ No newline at end of file diff --git a/setup/mrp_production_cost/setup.py b/setup/mrp_production_cost/setup.py new file mode 100644 index 000000000..28c57bb64 --- /dev/null +++ b/setup/mrp_production_cost/setup.py @@ -0,0 +1,6 @@ +import setuptools + +setuptools.setup( + setup_requires=['setuptools-odoo'], + odoo_addon=True, +)