Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[16.0][MIG] mrp_production_cost: Migration to 16.0 #364

Merged
merged 3 commits into from
Jul 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions mrp_production_cost/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
.. 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
===================

This module makes an estimation of the cost of a Manufacturing Order.

The user can visualise the cost data in the component lines, in the work orders and in the list of production orders.

Bug Tracker
===========

Bugs are tracked on `GitHub Issues
<https://github.com/avanzosc/mrp-addons/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 <[email protected]>
* Ana Juaristi <[email protected]>
1 change: 1 addition & 0 deletions mrp_production_cost/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import models
21 changes: 21 additions & 0 deletions mrp_production_cost/__manifest__.py
Original file line number Diff line number Diff line change
@@ -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": "Manufacturing/Manufacturing",
"license": "AGPL-3",
"version": "16.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,
}
93 changes: 93 additions & 0 deletions mrp_production_cost/i18n/es.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * mrp_production_cost
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 16.0\n"
"Report-Msgid-Bugs-To: \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"
"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_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_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_to_consume
#: model_terms:ir.ui.view,arch_db:mrp_production_cost.mrp_production_tree_view
msgid "Estimated Material Cost"
msgstr "Coste de material estimado"

#. module: mrp_production_cost
#: 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 "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 "Estimated Work Cost"
msgstr "Coste de trabajo estimado"

#. 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,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
msgid "Real Cost"
msgstr "Coste real"

#. module: mrp_production_cost
#: 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.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_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_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
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"
93 changes: 93 additions & 0 deletions mrp_production_cost/i18n/mrp_production_cost.pot
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * mrp_production_cost
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 16.0\n"
"Report-Msgid-Bugs-To: \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"
"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_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_estimated
msgid "Estimated Manufacturing 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_tree_view
msgid "Estimated Material Cost"
msgstr ""

#. module: mrp_production_cost
#: 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 "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 "Estimated Work Cost"
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,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
msgid "Real Cost"
msgstr ""

#. module: mrp_production_cost
#: 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.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_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_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
#: 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 ""
3 changes: 3 additions & 0 deletions mrp_production_cost/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from . import mrp_production
from . import stock_move
from . import mrp_workorder
90 changes: 90 additions & 0 deletions mrp_production_cost/models/mrp_production.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
# 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="Estimated Material Cost",
copy=False,
store=True,
compute="_compute_cost_material_to_consume",
)
cost_material_consumed = fields.Float(
string="Real Material Cost",
copy=False,
store=True,
compute="_compute_cost_material_consumed",
)
# Workorder costs
cost_workorder_estimated = fields.Float(
string="Estimated Work Cost",
copy=False,
store=True,
compute="_compute_cost_workorder_estimated",
)
cost_workorder_real = fields.Float(
string="Real Work Cost",
copy=False,
store=True,
compute="_compute_cost_workorder_real",
)
# Manufacturing costs
cost_manufacturing_estimated = fields.Float(
string="Estimated Manufacturing Cost",
copy=False,
store=True,
compute="_compute_cost_manufacturing_estimated",
)
cost_manufacturing_real = fields.Float(
string="Real Manufacturing Cost",
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.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.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.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.mapped("workorder_ids.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
)
30 changes: 30 additions & 0 deletions mrp_production_cost/models/mrp_workorder.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# 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"

workorder_cost_estimated = fields.Float(
string="Estimated Cost",
copy=False,
store=True,
compute="_compute_workorder_cost_estimated",
)
workorder_cost_real = fields.Float(
string="Real Cost",
copy=False,
store=True,
compute="_compute_workorder_cost_real",
)

@api.depends("duration_expected", "costs_hour")
def _compute_workorder_cost_estimated(self):
for order in self:
order.workorder_cost_estimated = order.costs_hour * order.duration_expected

@api.depends("duration", "costs_hour")
def _compute_workorder_cost_real(self):
for order in self:
order.workorder_cost_real = order.costs_hour * order.duration
30 changes: 30 additions & 0 deletions mrp_production_cost/models/stock_move.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# Copyright 2022 Patxi Lersundi
# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html
from odoo import api, fields, models


class StockMove(models.Model):
_inherit = "stock.move"

material_cost_to_consume = fields.Float(
string="Estimated Cost",
store=True,
copy=False,
compute="_compute_material_cost_to_consume",
)
material_cost_consumed = fields.Float(
string="Real Cost",
store=True,
copy=False,
compute="_compute_material_cost_consumed",
)

@api.depends("price_unit", "product_uom_qty")
def _compute_material_cost_to_consume(self):
for move in self:
move.material_cost_to_consume = move.price_unit * move.product_uom_qty

@api.depends("price_unit", "quantity_done")
def _compute_material_cost_consumed(self):
for move in self:
move.material_cost_consumed = move.price_unit * move.quantity_done
Loading
Loading