Skip to content
Open
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
91 changes: 91 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,91 @@
========================================================
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:69dd1971ee9a5ed3263b3ce2b4c7d787a4eeab8aa83a48b8fded37d307a64d55
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

.. |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/18.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-18-0/manufacture-reporting-18-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=18.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:

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

2. Select a BOM or more BOMS

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

3. Go to 'Print / Export Flattened BOM Structure 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:%2018.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 <[email protected]>
- Thinh Banh <[email protected]>

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/18.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": "18.0.1.0.1",
"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,
}
80 changes: 80 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,80 @@
# 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-11-12 17:38+0000\n"
"Last-Translator: mymage <[email protected]>\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
#. odoo-python
#: 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
#: model:ir.model.fields,field_description:mrp_flattened_bom_xlsx_direct_materials_cost.field_mrp_bom__direct_materials_cost
msgid "Direct Material Cost"
msgstr "Costo materiale diretto"

#. module: mrp_flattened_bom_xlsx_direct_materials_cost
#. odoo-python
#: 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,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
#. odoo-python
#: 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
#. odoo-python
#: 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 Variant"
msgstr "Variante prodotto"

#~ msgid "Direct Materials Cost"
#~ msgstr "Costo materiali diretti"

#~ msgid "Display Name"
#~ msgstr "Nome visualizzato"

#~ msgid "ID"
#~ msgstr "ID"

#~ msgid "Last Modified on"
#~ msgstr "Ultima modifica il"

#~ msgid "Product"
#~ msgstr "Prodotto"
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
# 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 16.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
#. odoo-python
#: 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
#: model:ir.model.fields,field_description:mrp_flattened_bom_xlsx_direct_materials_cost.field_mrp_bom__direct_materials_cost
msgid "Direct Material Cost"
msgstr ""

#. module: mrp_flattened_bom_xlsx_direct_materials_cost
#. odoo-python
#: 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,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
#. odoo-python
#: 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
#. odoo-python
#: 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 Variant"
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
14 changes: 14 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,14 @@
# 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()
if not self.standard_price and self.variant_seller_ids:
return self.variant_seller_ids[0].price
return self.standard_price
3 changes: 3 additions & 0 deletions mrp_flattened_bom_xlsx_direct_materials_cost/pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[build-system]
requires = ["whool"]
build-backend = "whool.buildapi"
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
- Bernat Puig Font \<[email protected]\>
- Thinh Banh \<[email protected]\>
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.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
To use this module, you need to:

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

2. Select a BOM or more BOMS

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

3. Go to 'Print / Export Flattened BOM Structure 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,46 @@
# 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

_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 = self.env._("Direct Materials")

sheet.set_column(6, 8, 20)
title_style = workbook.formats[2]
sheet_title = [
self.env._("Material Unit Cost"),
self.env._("Material Cost"),
self.env._("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