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 authored and anajuaristi committed Dec 18, 2024
1 parent eb23075 commit 5480fff
Show file tree
Hide file tree
Showing 17 changed files with 715 additions and 0 deletions.
31 changes: 31 additions & 0 deletions mrp_product_loss_cost/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
.. 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 "Components" tab, show the estimated and real cost of the scrap product.
* In MO new fields "Estimated Scrap Cost" and "Real Scrap Cost".
* This information is also displayed in the manufacturing tree view.

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>
22 changes: 22 additions & 0 deletions mrp_product_loss_cost/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
from . import models
from odoo import api, SUPERUSER_ID


def _post_install_put_cost_in_scrap(cr, registry):
"""
This method will set the production cost on already done manufacturing orders.
"""
env = api.Environment(cr, SUPERUSER_ID, {})
scraps = env["stock.scrap"].search([("state", "=", "done")])
for scrap in scraps:
scrap_unit_cost = scrap.product_id.standard_price
if scrap.lot_id and scrap.lot_id.purchase_price:
scrap_unit_cost = scrap.product_id.standard_price
scrap.write(
{
"scrap_unit_cost": scrap_unit_cost,
"scrap_cost": scrap_unit_cost * scrap.scrap_qty,
}
)
if scrap.production_id and scrap.production_id.state == "done":
scrap.production_id.update_prodution_cost()
19 changes: 19 additions & 0 deletions mrp_product_loss_cost/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# 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_production_cost", "mrp_product_loss"],
"data": [
"views/mrp_production_views.xml",
"views/stock_scrap_views.xml",
"views/stock_move_views.xml",
],
"installable": True,
"auto_install": True,
"post_init_hook": "_post_install_put_cost_in_scrap",
}
72 changes: 72 additions & 0 deletions mrp_product_loss_cost/i18n/ca_ES.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
# 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-23 07:32+0000\n"
"PO-Revision-Date: 2024-10-23 07:32+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_mrp_production__estimated_scrap_cost
#: model:ir.model.fields,field_description:mrp_product_loss_cost.field_stock_move__estimated_scrap_cost
#: model:ir.model.fields,field_description:mrp_product_loss_cost.field_stock_reservation__estimated_scrap_cost
#: model_terms:ir.ui.view,arch_db:mrp_product_loss_cost.mrp_production_form_view
msgid "Estimated Scrap Cost"
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.model.fields,field_description:mrp_product_loss_cost.field_mrp_production__real_scrap_cost
#: model:ir.model.fields,field_description:mrp_product_loss_cost.field_stock_move__real_scrap_cost
#: model:ir.model.fields,field_description:mrp_product_loss_cost.field_stock_reservation__real_scrap_cost
msgid "Real Scrap 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_stock_scrap__scrap_cost
msgid "Scrap Cost"
msgstr ""

#. module: mrp_product_loss_cost
#: model:ir.model.fields,field_description:mrp_product_loss_cost.field_stock_scrap__scrap_unit_cost
msgid "Scrap Unit Cost"
msgstr ""

#. module: mrp_product_loss_cost
#: model:ir.model,name:mrp_product_loss_cost.model_stock_move
msgid "Stock Move"
msgstr "Moviment d'estoc"

#. module: mrp_product_loss_cost
#: model_terms:ir.ui.view,arch_db:mrp_product_loss_cost.mrp_production_tree_view
msgid "Total Estimated Scrap 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 ""

#. module: mrp_product_loss_cost
#: model_terms:ir.ui.view,arch_db:mrp_product_loss_cost.mrp_production_form_view
msgid "real Scrap Cost"
msgstr ""
72 changes: 72 additions & 0 deletions mrp_product_loss_cost/i18n/en_GB.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
# 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-23 07:32+0000\n"
"PO-Revision-Date: 2024-10-23 07:32+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_mrp_production__estimated_scrap_cost
#: model:ir.model.fields,field_description:mrp_product_loss_cost.field_stock_move__estimated_scrap_cost
#: model:ir.model.fields,field_description:mrp_product_loss_cost.field_stock_reservation__estimated_scrap_cost
#: model_terms:ir.ui.view,arch_db:mrp_product_loss_cost.mrp_production_form_view
msgid "Estimated Scrap Cost"
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.model.fields,field_description:mrp_product_loss_cost.field_mrp_production__real_scrap_cost
#: model:ir.model.fields,field_description:mrp_product_loss_cost.field_stock_move__real_scrap_cost
#: model:ir.model.fields,field_description:mrp_product_loss_cost.field_stock_reservation__real_scrap_cost
msgid "Real Scrap 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_stock_scrap__scrap_cost
msgid "Scrap Cost"
msgstr ""

#. module: mrp_product_loss_cost
#: model:ir.model.fields,field_description:mrp_product_loss_cost.field_stock_scrap__scrap_unit_cost
msgid "Scrap Unit Cost"
msgstr ""

#. module: mrp_product_loss_cost
#: model:ir.model,name:mrp_product_loss_cost.model_stock_move
msgid "Stock Move"
msgstr ""

#. module: mrp_product_loss_cost
#: model_terms:ir.ui.view,arch_db:mrp_product_loss_cost.mrp_production_tree_view
msgid "Total Estimated Scrap 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 ""

#. module: mrp_product_loss_cost
#: model_terms:ir.ui.view,arch_db:mrp_product_loss_cost.mrp_production_form_view
msgid "real Scrap Cost"
msgstr ""
73 changes: 73 additions & 0 deletions mrp_product_loss_cost/i18n/es.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
# 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-23 07:33+0000\n"
"PO-Revision-Date: 2024-10-23 07:33+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_mrp_production__estimated_scrap_cost
#: model:ir.model.fields,field_description:mrp_product_loss_cost.field_stock_move__estimated_scrap_cost
#: model:ir.model.fields,field_description:mrp_product_loss_cost.field_stock_reservation__estimated_scrap_cost
#: model_terms:ir.ui.view,arch_db:mrp_product_loss_cost.mrp_production_form_view
msgid "Estimated Scrap Cost"
msgstr "Coste estimado desecho"

#. 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.model.fields,field_description:mrp_product_loss_cost.field_mrp_production__real_scrap_cost
#: model:ir.model.fields,field_description:mrp_product_loss_cost.field_stock_move__real_scrap_cost
#: model:ir.model.fields,field_description:mrp_product_loss_cost.field_stock_reservation__real_scrap_cost
msgid "Real Scrap Cost"
msgstr "Coste real desecho"

#. 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_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_stock_scrap__scrap_unit_cost
msgid "Scrap Unit Cost"
msgstr "Coste unitario desecho"

#. module: mrp_product_loss_cost
#: model:ir.model,name:mrp_product_loss_cost.model_stock_move
msgid "Stock Move"
msgstr "Movimiento de existencias"

#. module: mrp_product_loss_cost
#: model_terms:ir.ui.view,arch_db:mrp_product_loss_cost.mrp_production_tree_view
msgid "Total Estimated Scrap Cost"
msgstr "Total coste estimado desecho"

#. 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"

#. module: mrp_product_loss_cost
#: model_terms:ir.ui.view,arch_db:mrp_product_loss_cost.mrp_production_form_view
msgid "real Scrap Cost"
msgstr "Coste real desecho"

72 changes: 72 additions & 0 deletions mrp_product_loss_cost/i18n/fr.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
# 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-23 07:33+0000\n"
"PO-Revision-Date: 2024-10-23 07:33+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_mrp_production__estimated_scrap_cost
#: model:ir.model.fields,field_description:mrp_product_loss_cost.field_stock_move__estimated_scrap_cost
#: model:ir.model.fields,field_description:mrp_product_loss_cost.field_stock_reservation__estimated_scrap_cost
#: model_terms:ir.ui.view,arch_db:mrp_product_loss_cost.mrp_production_form_view
msgid "Estimated Scrap Cost"
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.model.fields,field_description:mrp_product_loss_cost.field_mrp_production__real_scrap_cost
#: model:ir.model.fields,field_description:mrp_product_loss_cost.field_stock_move__real_scrap_cost
#: model:ir.model.fields,field_description:mrp_product_loss_cost.field_stock_reservation__real_scrap_cost
msgid "Real Scrap 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_stock_scrap__scrap_cost
msgid "Scrap Cost"
msgstr ""

#. module: mrp_product_loss_cost
#: model:ir.model.fields,field_description:mrp_product_loss_cost.field_stock_scrap__scrap_unit_cost
msgid "Scrap Unit Cost"
msgstr ""

#. module: mrp_product_loss_cost
#: model:ir.model,name:mrp_product_loss_cost.model_stock_move
msgid "Stock Move"
msgstr "Mouvement de stock"

#. module: mrp_product_loss_cost
#: model_terms:ir.ui.view,arch_db:mrp_product_loss_cost.mrp_production_tree_view
msgid "Total Estimated Scrap 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 ""

#. module: mrp_product_loss_cost
#: model_terms:ir.ui.view,arch_db:mrp_product_loss_cost.mrp_production_form_view
msgid "real Scrap Cost"
msgstr ""
Loading

0 comments on commit 5480fff

Please sign in to comment.