diff --git a/mrp_bom_location/README.rst b/mrp_bom_location/README.rst new file mode 100644 index 000000000..2249d0d65 --- /dev/null +++ b/mrp_bom_location/README.rst @@ -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/13.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-13-0/manufacture-13-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/13.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 `_. +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 `_. + +Do not contact contributors directly about support or help with technical issues. + +Credits +======= + +Authors +~~~~~~~ + +* ForgeFlow + +Contributors +~~~~~~~~~~~~ + +* Lois Rilo +* Mykhailo Panarin +* Saran Limpajitkutaporn +* Sudhir Arya + +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 `_ project on GitHub. + +You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/mrp_bom_location/__init__.py b/mrp_bom_location/__init__.py new file mode 100644 index 000000000..bf588bc8b --- /dev/null +++ b/mrp_bom_location/__init__.py @@ -0,0 +1,2 @@ +from . import models +from . import report diff --git a/mrp_bom_location/__manifest__.py b/mrp_bom_location/__manifest__.py new file mode 100644 index 000000000..bc9291a87 --- /dev/null +++ b/mrp_bom_location/__manifest__.py @@ -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": "14.0.1.0.1", + "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, +} diff --git a/mrp_bom_location/i18n/de.po b/mrp_bom_location/i18n/de.po new file mode 100644 index 000000000..c42289a9c --- /dev/null +++ b/mrp_bom_location/i18n/de.po @@ -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 \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" diff --git a/mrp_bom_location/i18n/mrp_bom_location.pot b/mrp_bom_location/i18n/mrp_bom_location.pot new file mode 100644 index 000000000..f3de55fd4 --- /dev/null +++ b/mrp_bom_location/i18n/mrp_bom_location.pot @@ -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 13.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 "" diff --git a/mrp_bom_location/models/__init__.py b/mrp_bom_location/models/__init__.py new file mode 100644 index 000000000..a352efe9b --- /dev/null +++ b/mrp_bom_location/models/__init__.py @@ -0,0 +1 @@ +from . import mrp_bom diff --git a/mrp_bom_location/models/mrp_bom.py b/mrp_bom_location/models/mrp_bom.py new file mode 100644 index 000000000..941ae444f --- /dev/null +++ b/mrp_bom_location/models/mrp_bom.py @@ -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) diff --git a/mrp_bom_location/readme/CONTRIBUTORS.rst b/mrp_bom_location/readme/CONTRIBUTORS.rst new file mode 100644 index 000000000..d023289f4 --- /dev/null +++ b/mrp_bom_location/readme/CONTRIBUTORS.rst @@ -0,0 +1,4 @@ +* Lois Rilo +* Mykhailo Panarin +* Saran Limpajitkutaporn +* Sudhir Arya diff --git a/mrp_bom_location/readme/DESCRIPTION.rst b/mrp_bom_location/readme/DESCRIPTION.rst new file mode 100644 index 000000000..bdfc21f8b --- /dev/null +++ b/mrp_bom_location/readme/DESCRIPTION.rst @@ -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. diff --git a/mrp_bom_location/readme/USAGE.rst b/mrp_bom_location/readme/USAGE.rst new file mode 100644 index 000000000..401f96fa0 --- /dev/null +++ b/mrp_bom_location/readme/USAGE.rst @@ -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 diff --git a/mrp_bom_location/report/__init__.py b/mrp_bom_location/report/__init__.py new file mode 100644 index 000000000..df4f1117a --- /dev/null +++ b/mrp_bom_location/report/__init__.py @@ -0,0 +1 @@ +from . import bom_structure diff --git a/mrp_bom_location/report/bom_structure.py b/mrp_bom_location/report/bom_structure.py new file mode 100644 index 000000000..8b944f5d5 --- /dev/null +++ b/mrp_bom_location/report/bom_structure.py @@ -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 diff --git a/mrp_bom_location/static/description/icon.png b/mrp_bom_location/static/description/icon.png new file mode 100644 index 000000000..3a0328b51 Binary files /dev/null and b/mrp_bom_location/static/description/icon.png differ diff --git a/mrp_bom_location/static/description/index.html b/mrp_bom_location/static/description/index.html new file mode 100644 index 000000000..9ac464369 --- /dev/null +++ b/mrp_bom_location/static/description/index.html @@ -0,0 +1,434 @@ + + + + + + +MRP BOM Location + + + +
+

MRP BOM Location

+ + +

Beta License: LGPL-3 OCA/manufacture Translate me on Weblate Try me on Runbot

+

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

+ +
+

Usage

+

To use this module, you need to:

+
    +
  1. Go to Manufacturing > Bill of Materials.
  2. +
  3. Pick or create one of them.
  4. +
  5. You will see a new field to fill called “Location”.
  6. +
  7. On the structure report BOM > Print > BOM Structure location field is present
  8. +
+
+
+

Bug Tracker

+

Bugs are tracked on GitHub 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.

+

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

+
+
+

Credits

+
+

Authors

+
    +
  • ForgeFlow
  • +
+
+
+

Contributors

+ +
+
+

Maintainers

+

This module is maintained by the OCA.

+Odoo Community Association +

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 project on GitHub.

+

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

+
+
+
+ + diff --git a/mrp_bom_location/views/mrp_view.xml b/mrp_bom_location/views/mrp_view.xml new file mode 100644 index 000000000..27d2c1de1 --- /dev/null +++ b/mrp_bom_location/views/mrp_view.xml @@ -0,0 +1,63 @@ + + + + + mrp.bom.form - mrp_bom_location + mrp.bom + + + + + + + + + + + + + mrp.bom.tree - mrp_bom_location + mrp.bom + + + + + + + + + + mrp.bom.select - mrp_bom_location + mrp.bom + + + + + + + + + + + + + mrp.bom.line.view.form - mrp_bom_location + mrp.bom.line + + + + + + + + diff --git a/mrp_bom_location/views/report_mrpbomstructure.xml b/mrp_bom_location/views/report_mrpbomstructure.xml new file mode 100644 index 000000000..af1aafcc6 --- /dev/null +++ b/mrp_bom_location/views/report_mrpbomstructure.xml @@ -0,0 +1,58 @@ + + + + + + diff --git a/setup/mrp_bom_location/odoo/addons/mrp_bom_location b/setup/mrp_bom_location/odoo/addons/mrp_bom_location new file mode 120000 index 000000000..92e74ddbd --- /dev/null +++ b/setup/mrp_bom_location/odoo/addons/mrp_bom_location @@ -0,0 +1 @@ +../../../../mrp_bom_location \ No newline at end of file diff --git a/setup/mrp_bom_location/setup.py b/setup/mrp_bom_location/setup.py new file mode 100644 index 000000000..28c57bb64 --- /dev/null +++ b/setup/mrp_bom_location/setup.py @@ -0,0 +1,6 @@ +import setuptools + +setuptools.setup( + setup_requires=['setuptools-odoo'], + odoo_addon=True, +)