Skip to content

Commit

Permalink
Merge PR #116 into 16.0
Browse files Browse the repository at this point in the history
Signed-off-by LoisRForgeFlow
  • Loading branch information
OCA-git-bot committed Oct 25, 2023
2 parents 0f55850 + 8693429 commit eaeefea
Show file tree
Hide file tree
Showing 17 changed files with 809 additions and 0 deletions.
90 changes: 90 additions & 0 deletions mrp_flattened_bom_xlsx_direct_materials_cost/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
========================================================
Export Flattened BOM to Excel with direct materials cost
========================================================

..
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:2d0253cec8526e66a37d3c76f23485d883ffd03635fd3778415abdf51867249a
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
:target: https://odoo-community.org/page/development-status
:alt: Beta
.. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
:alt: License: AGPL-3
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fmanufacture--reporting-lightgray.png?logo=github
:target: https://github.com/OCA/manufacture-reporting/tree/14.0/mrp_flattened_bom_xlsx_direct_materials_cost
:alt: OCA/manufacture-reporting
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
:target: https://translation.odoo-community.org/projects/manufacture-reporting-14-0/manufacture-reporting-14-0-mrp_flattened_bom_xlsx_direct_materials_cost
:alt: Translate me on Weblate
.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png
:target: https://runboat.odoo-community.org/builds?repo=OCA/manufacture-reporting&target_branch=14.0
:alt: Try me on Runboat

|badge1| |badge2| |badge3| |badge4| |badge5|

This module extends the report of the Export Flattened BOM to
Excel module showing the direct material costs.

**Table of contents**

.. contents::
:local:

Usage
=====

To use this module, you need to:

#. Go to 'Manufacturing / Products / Bill of Materials'

#. Select a BOM or more BOMS

*(Could be interesting to modify quantities of these BOMs)*

#. Go to 'Print / Export Flattened BOM to Excel'.

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

Bugs are tracked on `GitHub Issues <https://github.com/OCA/manufacture-reporting/issues>`_.
In case of trouble, please check there if your issue has already been reported.
If you spotted it first, help us to smash it by providing a detailed and welcomed
`feedback <https://github.com/OCA/manufacture-reporting/issues/new?body=module:%20mrp_flattened_bom_xlsx_direct_materials_cost%0Aversion:%2014.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.

Do not contact contributors directly about support or help with technical issues.

Credits
=======

Authors
~~~~~~~

* ForgeFlow

Contributors
~~~~~~~~~~~~

* Bernat Puig Font <bernat.puig@forgeflow.com>

Maintainers
~~~~~~~~~~~

This module is maintained by the OCA.

.. image:: https://odoo-community.org/logo.png
:alt: Odoo Community Association
:target: https://odoo-community.org

OCA, or the Odoo Community Association, is a nonprofit organization whose
mission is to support the collaborative development of Odoo features and
promote its widespread use.

This module is part of the `OCA/manufacture-reporting <https://github.com/OCA/manufacture-reporting/tree/14.0/mrp_flattened_bom_xlsx_direct_materials_cost>`_ project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
2 changes: 2 additions & 0 deletions mrp_flattened_bom_xlsx_direct_materials_cost/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
from . import models
from . import report
13 changes: 13 additions & 0 deletions mrp_flattened_bom_xlsx_direct_materials_cost/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Copyright 2022 ForgeFlow S.L. (http://www.forgeflow.com)
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).

{
"name": "Export Flattened BOM to Excel with direct materials cost",
"version": "16.0.1.0.0",
"category": "Manufacturing",
"author": "ForgeFlow, Odoo Community Association (OCA)",
"website": "https://github.com/OCA/manufacture-reporting",
"license": "AGPL-3",
"depends": ["mrp_flattened_bom_xlsx"],
"installable": True,
}
82 changes: 82 additions & 0 deletions mrp_flattened_bom_xlsx_direct_materials_cost/i18n/it.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * mrp_flattened_bom_xlsx_direct_materials_cost
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 14.0\n"
"Report-Msgid-Bugs-To: \n"
"PO-Revision-Date: 2023-05-24 10:09+0000\n"
"Last-Translator: mymage <stefano.consolaro@mymage.it>\n"
"Language-Team: none\n"
"Language: it\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: nplurals=2; plural=n != 1;\n"
"X-Generator: Weblate 4.17\n"

#. module: mrp_flattened_bom_xlsx_direct_materials_cost
#: model:ir.model,name:mrp_flattened_bom_xlsx_direct_materials_cost.model_mrp_bom
msgid "Bill of Material"
msgstr "Distinta base"

#. module: mrp_flattened_bom_xlsx_direct_materials_cost
#: code:addons/mrp_flattened_bom_xlsx_direct_materials_cost/report/flattened_bom_xlsx.py:0
#, python-format
msgid "Currency"
msgstr "Valuta"

#. module: mrp_flattened_bom_xlsx_direct_materials_cost
#: code:addons/mrp_flattened_bom_xlsx_direct_materials_cost/report/flattened_bom_xlsx.py:0
#, python-format
msgid "Direct Materials"
msgstr "Materiali diretti"

#. module: mrp_flattened_bom_xlsx_direct_materials_cost
#: model:ir.model.fields,field_description:mrp_flattened_bom_xlsx_direct_materials_cost.field_mrp_bom__direct_materials_cost
msgid "Direct Materials Cost"
msgstr "Costo materiali diretti"

#. module: mrp_flattened_bom_xlsx_direct_materials_cost
#: model:ir.model.fields,field_description:mrp_flattened_bom_xlsx_direct_materials_cost.field_mrp_bom__display_name
#: model:ir.model.fields,field_description:mrp_flattened_bom_xlsx_direct_materials_cost.field_product_product__display_name
#: model:ir.model.fields,field_description:mrp_flattened_bom_xlsx_direct_materials_cost.field_report_mrp_flattened_bom_xlsx_flattened_bom_xlsx__display_name
msgid "Display Name"
msgstr "Nome visualizzato"

#. module: mrp_flattened_bom_xlsx_direct_materials_cost
#: model:ir.model,name:mrp_flattened_bom_xlsx_direct_materials_cost.model_report_mrp_flattened_bom_xlsx_flattened_bom_xlsx
msgid "Flattened BOM XLSX"
msgstr "XLSX distinta base tecnica"

#. module: mrp_flattened_bom_xlsx_direct_materials_cost
#: model:ir.model.fields,field_description:mrp_flattened_bom_xlsx_direct_materials_cost.field_mrp_bom__id
#: model:ir.model.fields,field_description:mrp_flattened_bom_xlsx_direct_materials_cost.field_product_product__id
#: model:ir.model.fields,field_description:mrp_flattened_bom_xlsx_direct_materials_cost.field_report_mrp_flattened_bom_xlsx_flattened_bom_xlsx__id
msgid "ID"
msgstr "ID"

#. module: mrp_flattened_bom_xlsx_direct_materials_cost
#: model:ir.model.fields,field_description:mrp_flattened_bom_xlsx_direct_materials_cost.field_mrp_bom____last_update
#: model:ir.model.fields,field_description:mrp_flattened_bom_xlsx_direct_materials_cost.field_product_product____last_update
#: model:ir.model.fields,field_description:mrp_flattened_bom_xlsx_direct_materials_cost.field_report_mrp_flattened_bom_xlsx_flattened_bom_xlsx____last_update
msgid "Last Modified on"
msgstr "Ultima modifica il"

#. module: mrp_flattened_bom_xlsx_direct_materials_cost
#: code:addons/mrp_flattened_bom_xlsx_direct_materials_cost/report/flattened_bom_xlsx.py:0
#, python-format
msgid "Material Cost"
msgstr "Costo materiale"

#. module: mrp_flattened_bom_xlsx_direct_materials_cost
#: code:addons/mrp_flattened_bom_xlsx_direct_materials_cost/report/flattened_bom_xlsx.py:0
#, python-format
msgid "Material Unit Cost"
msgstr "Costo unitario materiale"

#. module: mrp_flattened_bom_xlsx_direct_materials_cost
#: model:ir.model,name:mrp_flattened_bom_xlsx_direct_materials_cost.model_product_product
msgid "Product"
msgstr "Prodotto"
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * mrp_flattened_bom_xlsx_direct_materials_cost
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 14.0\n"
"Report-Msgid-Bugs-To: \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_flattened_bom_xlsx_direct_materials_cost
#: model:ir.model,name:mrp_flattened_bom_xlsx_direct_materials_cost.model_mrp_bom
msgid "Bill of Material"
msgstr ""

#. module: mrp_flattened_bom_xlsx_direct_materials_cost
#: code:addons/mrp_flattened_bom_xlsx_direct_materials_cost/report/flattened_bom_xlsx.py:0
#, python-format
msgid "Currency"
msgstr ""

#. module: mrp_flattened_bom_xlsx_direct_materials_cost
#: code:addons/mrp_flattened_bom_xlsx_direct_materials_cost/report/flattened_bom_xlsx.py:0
#, python-format
msgid "Direct Materials"
msgstr ""

#. module: mrp_flattened_bom_xlsx_direct_materials_cost
#: model:ir.model.fields,field_description:mrp_flattened_bom_xlsx_direct_materials_cost.field_mrp_bom__direct_materials_cost
msgid "Direct Materials Cost"
msgstr ""

#. module: mrp_flattened_bom_xlsx_direct_materials_cost
#: model:ir.model.fields,field_description:mrp_flattened_bom_xlsx_direct_materials_cost.field_mrp_bom__display_name
#: model:ir.model.fields,field_description:mrp_flattened_bom_xlsx_direct_materials_cost.field_product_product__display_name
#: model:ir.model.fields,field_description:mrp_flattened_bom_xlsx_direct_materials_cost.field_report_mrp_flattened_bom_xlsx_flattened_bom_xlsx__display_name
msgid "Display Name"
msgstr ""

#. module: mrp_flattened_bom_xlsx_direct_materials_cost
#: model:ir.model,name:mrp_flattened_bom_xlsx_direct_materials_cost.model_report_mrp_flattened_bom_xlsx_flattened_bom_xlsx
msgid "Flattened BOM XLSX"
msgstr ""

#. module: mrp_flattened_bom_xlsx_direct_materials_cost
#: model:ir.model.fields,field_description:mrp_flattened_bom_xlsx_direct_materials_cost.field_mrp_bom__id
#: model:ir.model.fields,field_description:mrp_flattened_bom_xlsx_direct_materials_cost.field_product_product__id
#: model:ir.model.fields,field_description:mrp_flattened_bom_xlsx_direct_materials_cost.field_report_mrp_flattened_bom_xlsx_flattened_bom_xlsx__id
msgid "ID"
msgstr ""

#. module: mrp_flattened_bom_xlsx_direct_materials_cost
#: model:ir.model.fields,field_description:mrp_flattened_bom_xlsx_direct_materials_cost.field_mrp_bom____last_update
#: model:ir.model.fields,field_description:mrp_flattened_bom_xlsx_direct_materials_cost.field_product_product____last_update
#: model:ir.model.fields,field_description:mrp_flattened_bom_xlsx_direct_materials_cost.field_report_mrp_flattened_bom_xlsx_flattened_bom_xlsx____last_update
msgid "Last Modified on"
msgstr ""

#. module: mrp_flattened_bom_xlsx_direct_materials_cost
#: code:addons/mrp_flattened_bom_xlsx_direct_materials_cost/report/flattened_bom_xlsx.py:0
#, python-format
msgid "Material Cost"
msgstr ""

#. module: mrp_flattened_bom_xlsx_direct_materials_cost
#: code:addons/mrp_flattened_bom_xlsx_direct_materials_cost/report/flattened_bom_xlsx.py:0
#, python-format
msgid "Material Unit Cost"
msgstr ""

#. module: mrp_flattened_bom_xlsx_direct_materials_cost
#: model:ir.model,name:mrp_flattened_bom_xlsx_direct_materials_cost.model_product_product
msgid "Product"
msgstr ""
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
from . import mrp_bom
from . import product
25 changes: 25 additions & 0 deletions mrp_flattened_bom_xlsx_direct_materials_cost/models/mrp_bom.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Copyright 2022 ForgeFlow S.L.
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).

from odoo import fields, models


class MrpBom(models.Model):
_inherit = "mrp.bom"

direct_materials_cost = fields.Float(
string="Direct Material Cost",
compute="_compute_direct_materials_cost",
digits="Product Price",
)

def _compute_direct_materials_cost(self):
for bom in self:
price = 0.0
starting_factor = bom.product_uom_id._compute_quantity(
bom.product_qty, bom.product_tmpl_id.uom_id, round=False
)
totals = bom._get_flattened_totals(factor=starting_factor)
for product, total_qty in totals.items():
price += total_qty * product._get_direct_material_unit_cost()
bom.direct_materials_cost = price
12 changes: 12 additions & 0 deletions mrp_flattened_bom_xlsx_direct_materials_cost/models/product.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Copyright 2023 ForgeFlow S.L. (http://www.forgeflow.com)
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).

from odoo import models


class ProductProduct(models.Model):
_inherit = "product.product"

def _get_direct_material_unit_cost(self):
self.ensure_one()
return self.standard_price
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* Bernat Puig Font <bernat.puig@forgeflow.com>
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
This module extends the report of the Export Flattened BOM to
Excel module showing the direct material costs.
9 changes: 9 additions & 0 deletions mrp_flattened_bom_xlsx_direct_materials_cost/readme/USAGE.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
To use this module, you need to:

#. Go to 'Manufacturing / Products / Bill of Materials'

#. Select a BOM or more BOMS

*(Could be interesting to modify quantities of these BOMs)*

#. Go to 'Print / Export Flattened BOM to Excel'.
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
from . import flattened_bom_xlsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# Copyright 2022 ForgeFlow S.L. (http://www.forgeflow.com)
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).

import logging

from odoo import models
from odoo.tools.translate import _

_logger = logging.getLogger(__name__)


class FlattenedBomXlsx(models.AbstractModel):
_inherit = "report.mrp_flattened_bom_xlsx.flattened_bom_xlsx"

def generate_xlsx_report(self, workbook, data, objects):
res = super().generate_xlsx_report(workbook, data, objects)
sheet = workbook.worksheets_objs[0]
sheet.name = _("Direct Materials")

sheet.set_column(6, 8, 20)
title_style = workbook.formats[2]
sheet_title = [
_("Material Unit Cost"),
_("Material Cost"),
_("Currency"),
]
sheet.set_row(0, None, None, {"collapsed": 1})
sheet.write_row(1, 6, sheet_title, title_style)

i = 2
for o in objects:
sheet.write(i, 7, o.direct_materials_cost or 0.0)
sheet.write(i, 8, o.product_tmpl_id.currency_id.symbol or "")
i += 1

# We need to calculate the totals for the BoM qty and UoM:
starting_factor = o.product_uom_id._compute_quantity(
o.product_qty, o.product_tmpl_id.uom_id, round=False
)
requirements = o._get_flattened_totals(factor=starting_factor)
for product, total_qty in requirements.items():
unit_cost = product._get_direct_material_unit_cost()
sheet.write(i, 6, unit_cost or 0.0)
sheet.write(i, 7, unit_cost * total_qty or 0.0)
sheet.write(i, 8, product.currency_id.symbol or "")
i += 1
return res
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit eaeefea

Please sign in to comment.