Skip to content

Commit

Permalink
Merge PR #936 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 Jun 6, 2023
2 parents 34e6c26 + 97b2b21 commit c26c544
Show file tree
Hide file tree
Showing 19 changed files with 848 additions and 0 deletions.
88 changes: 88 additions & 0 deletions mrp_bom_location/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
================
MRP BOM Location
================

.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
.. |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-LGPL--3-blue.png
:target: http://www.gnu.org/licenses/lgpl-3.0-standalone.html
:alt: License: LGPL-3
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fmanufacture-lightgray.png?logo=github
:target: https://github.com/OCA/manufacture/tree/15.0/mrp_bom_location
:alt: OCA/manufacture
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
:target: https://translation.odoo-community.org/projects/manufacture-15-0/manufacture-15-0-mrp_bom_location
:alt: Translate me on Weblate
.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png
:target: https://runbot.odoo-community.org/runbot/129/15.0
:alt: Try me on Runbot

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

This module adds the location field to the Bill of Materials and its components. This may be useful to distinguish between different BoMs for the same product or to highlight the preferred locations to fetch the components from.

The location appears in the BOM Structure Report.

**Table of contents**

.. contents::
:local:

Usage
=====

To use this module, you need to:

#. Go to *Manufacturing > Bill of Materials*.
#. Pick or create one of them.
#. You will see a new field to fill called "Location".
#. On the structure report *BOM > Print > BOM Structure* location field is present

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

Bugs are tracked on `GitHub Issues <https://github.com/OCA/manufacture/issues>`_.
In case of trouble, please check there if your issue has already been reported.
If you spotted it first, help us smashing it by providing a detailed and welcomed
`feedback <https://github.com/OCA/manufacture/issues/new?body=module:%20mrp_bom_location%0Aversion:%2015.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
~~~~~~~~~~~~

* Lois Rilo <lois.rilo@forgeflow.com>
* Mykhailo Panarin <m.panarin@mobilunity.com>
* Saran Limpajitkutaporn <saranl@ecosoft.co.th>
* Sudhir Arya <sudhir@erpharbor.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 <https://github.com/OCA/manufacture/tree/15.0/mrp_bom_location>`_ 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_bom_location/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
from . import models
from . import report
15 changes: 15 additions & 0 deletions mrp_bom_location/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Copyright 2017-20 ForgeFlow S.L. (https://www.forgeflow.com)
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl).
{
"name": "MRP BOM Location",
"summary": "Adds location field to Bill of Materials and its components.",
"version": "16.0.1.0.0",
"category": "Manufacture",
"website": "https://github.com/OCA/manufacture",
"author": "ForgeFlow, Odoo Community Association (OCA)",
"license": "LGPL-3",
"application": False,
"depends": ["mrp"],
"data": ["views/mrp_view.xml", "views/report_mrpbomstructure.xml"],
"installable": True,
}
52 changes: 52 additions & 0 deletions mrp_bom_location/i18n/de.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * mrp_bom_location
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 11.0\n"
"Report-Msgid-Bugs-To: \n"
"PO-Revision-Date: 2018-12-09 10:43+0000\n"
"Last-Translator: Maria Sparenberg <maria.sparenberg@gmx.net>\n"
"Language-Team: none\n"
"Language: de\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 3.3\n"

#. module: mrp_bom_location
#: model:ir.model,name:mrp_bom_location.model_report_mrp_report_bom_structure
msgid "BOM Structure Report"
msgstr ""

#. module: mrp_bom_location
#: model:ir.model,name:mrp_bom_location.model_mrp_bom
msgid "Bill of Material"
msgstr "Stückliste"

#. module: mrp_bom_location
#: model:ir.model,name:mrp_bom_location.model_mrp_bom_line
#, fuzzy
msgid "Bill of Material Line"
msgstr "Stückliste"

#. module: mrp_bom_location
#: model:ir.model.fields,field_description:mrp_bom_location.field_mrp_bom__location_id
#: model:ir.model.fields,field_description:mrp_bom_location.field_mrp_bom_line__location_id
#: model_terms:ir.ui.view,arch_db:mrp_bom_location.report_mrpbomstructure_location
#: model_terms:ir.ui.view,arch_db:mrp_bom_location.view_mrp_bom_filter
msgid "Location"
msgstr "Lagerort"

#. module: mrp_bom_location
#: model_terms:ir.ui.view,arch_db:mrp_bom_location.report_mrpbomstructure_location
msgid "Location of the product"
msgstr ""

#~ msgid "mrp.bom.line"
#~ msgstr "mrp.bom.line"

#~ msgid "report.mrp.mrp_bom_structure_report"
#~ msgstr "report.mrp.mrp_bom_structure_report"
45 changes: 45 additions & 0 deletions mrp_bom_location/i18n/it.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * mrp_bom_location
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 15.0\n"
"Report-Msgid-Bugs-To: \n"
"PO-Revision-Date: 2023-01-01 13:45+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.14.1\n"

#. module: mrp_bom_location
#: model:ir.model,name:mrp_bom_location.model_report_mrp_report_bom_structure
msgid "BOM Structure Report"
msgstr "Resoconto struttura DiBa"

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

#. module: mrp_bom_location
#: model:ir.model,name:mrp_bom_location.model_mrp_bom_line
msgid "Bill of Material Line"
msgstr "Riga distinta base"

#. module: mrp_bom_location
#: model:ir.model.fields,field_description:mrp_bom_location.field_mrp_bom__location_id
#: model:ir.model.fields,field_description:mrp_bom_location.field_mrp_bom_line__location_id
#: model_terms:ir.ui.view,arch_db:mrp_bom_location.report_mrpbomstructure_location
#: model_terms:ir.ui.view,arch_db:mrp_bom_location.view_mrp_bom_filter
msgid "Location"
msgstr "Ubicazione"

#. module: mrp_bom_location
#: model_terms:ir.ui.view,arch_db:mrp_bom_location.report_mrpbomstructure_location
msgid "Location of the product"
msgstr "Ubicazione del prodotto"
42 changes: 42 additions & 0 deletions mrp_bom_location/i18n/mrp_bom_location.pot
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * mrp_bom_location
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 15.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_bom_location
#: model:ir.model,name:mrp_bom_location.model_report_mrp_report_bom_structure
msgid "BOM Structure Report"
msgstr ""

#. module: mrp_bom_location
#: model:ir.model,name:mrp_bom_location.model_mrp_bom
msgid "Bill of Material"
msgstr ""

#. module: mrp_bom_location
#: model:ir.model,name:mrp_bom_location.model_mrp_bom_line
msgid "Bill of Material Line"
msgstr ""

#. module: mrp_bom_location
#: model:ir.model.fields,field_description:mrp_bom_location.field_mrp_bom__location_id
#: model:ir.model.fields,field_description:mrp_bom_location.field_mrp_bom_line__location_id
#: model_terms:ir.ui.view,arch_db:mrp_bom_location.report_mrpbomstructure_location
#: model_terms:ir.ui.view,arch_db:mrp_bom_location.view_mrp_bom_filter
msgid "Location"
msgstr ""

#. module: mrp_bom_location
#: model_terms:ir.ui.view,arch_db:mrp_bom_location.report_mrpbomstructure_location
msgid "Location of the product"
msgstr ""
1 change: 1 addition & 0 deletions mrp_bom_location/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import mrp_bom
21 changes: 21 additions & 0 deletions mrp_bom_location/models/mrp_bom.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Copyright 2017-20 ForgeFlow S.L. (https://www.forgeflow.com)
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl).

from odoo import api, fields, models


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

location_id = fields.Many2one(string="Location", comodel_name="stock.location")

@api.onchange("picking_type_id")
def _onchange_picking_type_id(self):
if self.picking_type_id and self.picking_type_id.default_location_src_id:
self.location_id = self.picking_type_id.default_location_src_id


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

location_id = fields.Many2one(related="bom_id.location_id", store=True)
4 changes: 4 additions & 0 deletions mrp_bom_location/readme/CONTRIBUTORS.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
* Lois Rilo <lois.rilo@forgeflow.com>
* Mykhailo Panarin <m.panarin@mobilunity.com>
* Saran Limpajitkutaporn <saranl@ecosoft.co.th>
* Sudhir Arya <sudhir@erpharbor.com>
3 changes: 3 additions & 0 deletions mrp_bom_location/readme/DESCRIPTION.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
This module adds the location field to the Bill of Materials and its components. This may be useful to distinguish between different BoMs for the same product or to highlight the preferred locations to fetch the components from.

The location appears in the BOM Structure Report.
6 changes: 6 additions & 0 deletions mrp_bom_location/readme/USAGE.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
To use this module, you need to:

#. Go to *Manufacturing > Bill of Materials*.
#. Pick or create one of them.
#. You will see a new field to fill called "Location".
#. On the structure report *BOM > Print > BOM Structure* location field is present
1 change: 1 addition & 0 deletions mrp_bom_location/report/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import bom_structure
36 changes: 36 additions & 0 deletions mrp_bom_location/report/bom_structure.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# Copyright 2017-20 ForgeFlow S.L. (https://www.forgeflow.com)
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl).

from odoo import api, models


class BomStructureReport(models.AbstractModel):
_inherit = "report.mrp.report_bom_structure"

@api.model
def _get_bom_lines(self, bom, bom_quantity, product, line_id, level):
res = super(BomStructureReport, self)._get_bom_lines(
bom, bom_quantity, product, line_id, level
)
line_ids = self.env["mrp.bom.line"].search([("bom_id", "=", bom.id)])
for line in res[0]:
line_id = line_ids.filtered(
lambda l: l.location_id and l.id == line["line_id"]
)
line["location_id"] = line_id.location_id or ""
return res

@api.model
def _get_pdf_line(
self, bom_id, product_id=False, qty=1, child_bom_ids=None, unfolded=False
):
res = super(BomStructureReport, self)._get_pdf_line(
bom_id, product_id, qty, child_bom_ids, unfolded
)
line_ids = self.env["mrp.bom.line"].search([("bom_id", "=", bom_id)])
for line in res["lines"]:
line_id = line_ids.filtered(
lambda l: l.location_id and l.product_id.display_name == line["name"]
)
line["location_name"] = line_id.location_id.complete_name or ""
return res
Binary file added mrp_bom_location/static/description/icon.png
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 c26c544

Please sign in to comment.