Skip to content

Commit

Permalink
[16.0][ADD] mrp_product_loss_cost: Calculate the cost of product scrap.
Browse files Browse the repository at this point in the history
  • Loading branch information
alfredoavanzosc committed Oct 18, 2024
1 parent 96393bd commit c3bef6e
Show file tree
Hide file tree
Showing 15 changed files with 508 additions and 0 deletions.
29 changes: 29 additions & 0 deletions mrp_product_loss_cost/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
.. 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 product loss cost
=====================

* Calculate the cost of product scrap.
* In MO new fields "Scrap Cost" and "Total MO Cost".

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
------------

* Ana Juaristi <anajuaristi@avanzosc.es>
* Alfredo de la Fuente <alfredodelafuente@avanzosc.es>
1 change: 1 addition & 0 deletions mrp_product_loss_cost/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import models
18 changes: 18 additions & 0 deletions mrp_product_loss_cost/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Copyright 2024 Alfredo de la Fuente - AvanzOSC
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
{
"name": "Mrp Product Loss Cost",
"version": "16.0.1.0.0",
"category": "Manufacturing/Manufacturing",
"website": "https://github.com/avanzosc/mrp-addons",
"author": "AvanzOSC",
"license": "AGPL-3",
"depends": [
"mrp_stock_move_cost",
],
"data": [
"views/mrp_production_views.xml",
"views/stock_scrap_views.xml",
],
"installable": True,
}
54 changes: 54 additions & 0 deletions mrp_product_loss_cost/i18n/ca_ES.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * mrp_product_loss_cost
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 16.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2024-10-17 05:50+0000\n"
"PO-Revision-Date: 2024-10-17 05:50+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_product_loss_cost
#: model:ir.model.fields,field_description:mrp_product_loss_cost.field_stock_scrap__price_unit_cost
msgid "Cost Unit Price"
msgstr ""

#. module: mrp_product_loss_cost
#: model:ir.model,name:mrp_product_loss_cost.model_mrp_production
msgid "Production Order"
msgstr "Ordre de producció"

#. module: mrp_product_loss_cost
#: model:ir.actions.server,name:mrp_product_loss_cost.action_cost_in_mrp_production
msgid "Put Cost"
msgstr ""

#. module: mrp_product_loss_cost
#: model:ir.model,name:mrp_product_loss_cost.model_stock_scrap
msgid "Scrap"
msgstr "Deixalla"

#. module: mrp_product_loss_cost
#: model:ir.model.fields,field_description:mrp_product_loss_cost.field_mrp_production__scrap_cost
#: model:ir.model.fields,field_description:mrp_product_loss_cost.field_stock_scrap__scrap_cost
msgid "Scrap Cost"
msgstr ""

#. module: mrp_product_loss_cost
#: model:ir.model.fields,field_description:mrp_product_loss_cost.field_mrp_production__total_cost
#: model_terms:ir.ui.view,arch_db:mrp_product_loss_cost.mrp_production_tree_view
msgid "Total MO Cost"
msgstr ""

#. module: mrp_product_loss_cost
#: model_terms:ir.ui.view,arch_db:mrp_product_loss_cost.mrp_production_tree_view
#: model_terms:ir.ui.view,arch_db:mrp_product_loss_cost.stock_scrap_tree_view
msgid "Total Scrap Cost"
msgstr ""
54 changes: 54 additions & 0 deletions mrp_product_loss_cost/i18n/en_GB.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * mrp_product_loss_cost
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 16.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2024-10-17 05:50+0000\n"
"PO-Revision-Date: 2024-10-17 05:50+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_product_loss_cost
#: model:ir.model.fields,field_description:mrp_product_loss_cost.field_stock_scrap__price_unit_cost
msgid "Cost Unit Price"
msgstr ""

#. module: mrp_product_loss_cost
#: model:ir.model,name:mrp_product_loss_cost.model_mrp_production
msgid "Production Order"
msgstr ""

#. module: mrp_product_loss_cost
#: model:ir.actions.server,name:mrp_product_loss_cost.action_cost_in_mrp_production
msgid "Put Cost"
msgstr ""

#. module: mrp_product_loss_cost
#: model:ir.model,name:mrp_product_loss_cost.model_stock_scrap
msgid "Scrap"
msgstr ""

#. module: mrp_product_loss_cost
#: model:ir.model.fields,field_description:mrp_product_loss_cost.field_mrp_production__scrap_cost
#: model:ir.model.fields,field_description:mrp_product_loss_cost.field_stock_scrap__scrap_cost
msgid "Scrap Cost"
msgstr ""

#. module: mrp_product_loss_cost
#: model:ir.model.fields,field_description:mrp_product_loss_cost.field_mrp_production__total_cost
#: model_terms:ir.ui.view,arch_db:mrp_product_loss_cost.mrp_production_tree_view
msgid "Total MO Cost"
msgstr ""

#. module: mrp_product_loss_cost
#: model_terms:ir.ui.view,arch_db:mrp_product_loss_cost.mrp_production_tree_view
#: model_terms:ir.ui.view,arch_db:mrp_product_loss_cost.stock_scrap_tree_view
msgid "Total Scrap Cost"
msgstr ""
54 changes: 54 additions & 0 deletions mrp_product_loss_cost/i18n/es.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * mrp_product_loss_cost
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 16.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2024-10-17 05:51+0000\n"
"PO-Revision-Date: 2024-10-17 05:51+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_product_loss_cost
#: model:ir.model.fields,field_description:mrp_product_loss_cost.field_stock_scrap__price_unit_cost
msgid "Cost Unit Price"
msgstr "Precio coste unitario"

#. module: mrp_product_loss_cost
#: model:ir.model,name:mrp_product_loss_cost.model_mrp_production
msgid "Production Order"
msgstr "Orden de producción"

#. module: mrp_product_loss_cost
#: model:ir.actions.server,name:mrp_product_loss_cost.action_cost_in_mrp_production
msgid "Put Cost"
msgstr "Poner coste"

#. module: mrp_product_loss_cost
#: model:ir.model,name:mrp_product_loss_cost.model_stock_scrap
msgid "Scrap"
msgstr "Desechar"

#. module: mrp_product_loss_cost
#: model:ir.model.fields,field_description:mrp_product_loss_cost.field_mrp_production__scrap_cost
#: model:ir.model.fields,field_description:mrp_product_loss_cost.field_stock_scrap__scrap_cost
msgid "Scrap Cost"
msgstr "Coste desecho"

#. module: mrp_product_loss_cost
#: model:ir.model.fields,field_description:mrp_product_loss_cost.field_mrp_production__total_cost
#: model_terms:ir.ui.view,arch_db:mrp_product_loss_cost.mrp_production_tree_view
msgid "Total MO Cost"
msgstr "Total coste OF"

#. module: mrp_product_loss_cost
#: model_terms:ir.ui.view,arch_db:mrp_product_loss_cost.mrp_production_tree_view
#: model_terms:ir.ui.view,arch_db:mrp_product_loss_cost.stock_scrap_tree_view
msgid "Total Scrap Cost"
msgstr "Total coste desecho"
54 changes: 54 additions & 0 deletions mrp_product_loss_cost/i18n/fr.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * mrp_product_loss_cost
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 16.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2024-10-17 05:50+0000\n"
"PO-Revision-Date: 2024-10-17 05:50+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_product_loss_cost
#: model:ir.model.fields,field_description:mrp_product_loss_cost.field_stock_scrap__price_unit_cost
msgid "Cost Unit Price"
msgstr ""

#. module: mrp_product_loss_cost
#: model:ir.model,name:mrp_product_loss_cost.model_mrp_production
msgid "Production Order"
msgstr "Ordre de production"

#. module: mrp_product_loss_cost
#: model:ir.actions.server,name:mrp_product_loss_cost.action_cost_in_mrp_production
msgid "Put Cost"
msgstr ""

#. module: mrp_product_loss_cost
#: model:ir.model,name:mrp_product_loss_cost.model_stock_scrap
msgid "Scrap"
msgstr "Rebut"

#. module: mrp_product_loss_cost
#: model:ir.model.fields,field_description:mrp_product_loss_cost.field_mrp_production__scrap_cost
#: model:ir.model.fields,field_description:mrp_product_loss_cost.field_stock_scrap__scrap_cost
msgid "Scrap Cost"
msgstr ""

#. module: mrp_product_loss_cost
#: model:ir.model.fields,field_description:mrp_product_loss_cost.field_mrp_production__total_cost
#: model_terms:ir.ui.view,arch_db:mrp_product_loss_cost.mrp_production_tree_view
msgid "Total MO Cost"
msgstr ""

#. module: mrp_product_loss_cost
#: model_terms:ir.ui.view,arch_db:mrp_product_loss_cost.mrp_production_tree_view
#: model_terms:ir.ui.view,arch_db:mrp_product_loss_cost.stock_scrap_tree_view
msgid "Total Scrap Cost"
msgstr ""
54 changes: 54 additions & 0 deletions mrp_product_loss_cost/i18n/mrp_product_loss_cost.pot
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * mrp_product_loss_cost
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 16.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2024-10-17 05:49+0000\n"
"PO-Revision-Date: 2024-10-17 05:49+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_product_loss_cost
#: model:ir.model.fields,field_description:mrp_product_loss_cost.field_stock_scrap__price_unit_cost
msgid "Cost Unit Price"
msgstr ""

#. module: mrp_product_loss_cost
#: model:ir.model,name:mrp_product_loss_cost.model_mrp_production
msgid "Production Order"
msgstr ""

#. module: mrp_product_loss_cost
#: model:ir.actions.server,name:mrp_product_loss_cost.action_cost_in_mrp_production
msgid "Put Cost"
msgstr ""

#. module: mrp_product_loss_cost
#: model:ir.model,name:mrp_product_loss_cost.model_stock_scrap
msgid "Scrap"
msgstr ""

#. module: mrp_product_loss_cost
#: model:ir.model.fields,field_description:mrp_product_loss_cost.field_mrp_production__scrap_cost
#: model:ir.model.fields,field_description:mrp_product_loss_cost.field_stock_scrap__scrap_cost
msgid "Scrap Cost"
msgstr ""

#. module: mrp_product_loss_cost
#: model:ir.model.fields,field_description:mrp_product_loss_cost.field_mrp_production__total_cost
#: model_terms:ir.ui.view,arch_db:mrp_product_loss_cost.mrp_production_tree_view
msgid "Total MO Cost"
msgstr ""

#. module: mrp_product_loss_cost
#: model_terms:ir.ui.view,arch_db:mrp_product_loss_cost.mrp_production_tree_view
#: model_terms:ir.ui.view,arch_db:mrp_product_loss_cost.stock_scrap_tree_view
msgid "Total Scrap Cost"
msgstr ""
2 changes: 2 additions & 0 deletions mrp_product_loss_cost/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
from . import mrp_production
from . import stock_scrap
34 changes: 34 additions & 0 deletions mrp_product_loss_cost/models/mrp_production.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# Copyright 2024 Alfredo de la Fuente - AvanzOSC
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
from odoo import fields, models


class MrpProduction(models.Model):
_inherit = "mrp.production"

scrap_cost = fields.Float(digits="Product Price", copy=False)
total_cost = fields.Float(
string="Total MO Cost", digits="Product Price", copy=False
)

def update_prodution_cost(self):
result = super().update_prodution_cost()
scrap_cost = 0
price_unit_cost = 0
if self.scrap_ids:
scrap_cost = sum(self.scrap_ids.mapped("scrap_cost"))
total_of_cost = self.cost + scrap_cost
if total_of_cost and self.move_finished_ids:
for move in self.move_finished_ids:
if move.qty_done > 0:
move.price_unit_cost = total_of_cost / move.qty_done
if total_of_cost and self.qty_producing:
price_unit_cost = total_of_cost / self.qty_producing
self.scrap_cost = scrap_cost
self.total_cost = total_of_cost
self.price_unit_cost = price_unit_cost
if self.lot_producing_id:
self.lot_producing_id.with_context(from_production=True).purchase_price = (
price_unit_cost
)
return result
Loading

0 comments on commit c3bef6e

Please sign in to comment.