diff --git a/mrp_bom_location/README.rst b/mrp_bom_location/README.rst index 2179a654b..23f689cd7 100644 --- a/mrp_bom_location/README.rst +++ b/mrp_bom_location/README.rst @@ -1,18 +1,38 @@ -.. image:: https://img.shields.io/badge/licence-AGPL--3-blue.png - :target: https://www.gnu.org/licenses/agpl - :alt: License: AGPL-3 - ================ MRP BOM Location ================ -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. +.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! 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-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-lightgray.png?logo=github + :target: https://github.com/OCA/manufacture/tree/12.0-mig-mrp_bom_location/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-12-0-mig-mrp_bom_location/manufacture-12-0-mig-mrp_bom_location-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/12.0-mig-mrp_bom_location + :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 ===== @@ -24,46 +44,44 @@ To use this module, you need to: #. You will see a new field to fill called "Location". #. One the structure report *BOM > Print > BOM Structure* location field is present -.. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas - :alt: Try me on Runbot - :target: https://runbot.odoo-community.org/runbot/129/11.0 - 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 smash it by providing detailed and welcomed feedback. +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 ======= -Images ------- +Authors +~~~~~~~ -* Odoo Community Association: `Icon `_. +* Eficent Contributors ------------- +~~~~~~~~~~~~ * Lois Rilo * Mykhailo Panarin +* Saran Limpajitkutaporn -Do not contact contributors directly about support or help with technical -issues. +Maintainers +~~~~~~~~~~~ -Maintainer ----------- +This module is maintained by the OCA. .. image:: https://odoo-community.org/logo.png :alt: Odoo Community Association :target: https://odoo-community.org -This module is maintained by the OCA. - 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. -To contribute to this module, please visit https://odoo-community.org. +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/__manifest__.py b/mrp_bom_location/__manifest__.py index 6aa0b696b..c5bee45b3 100644 --- a/mrp_bom_location/__manifest__.py +++ b/mrp_bom_location/__manifest__.py @@ -3,7 +3,7 @@ { "name": "MRP BOM Location", "summary": "Adds location field to Bill of Materials and its components.", - "version": "11.0.1.0.0", + "version": "12.0.1.0.0", "category": "Manufacture", "website": "https://github.com/OCA/manufacture", "author": "Eficent, Odoo Community Association (OCA)", @@ -16,4 +16,5 @@ "views/mrp_view.xml", "views/report_mrpbomstructure.xml", ], + "installable": True } diff --git a/mrp_bom_location/models/mrp_bom.py b/mrp_bom_location/models/mrp_bom.py index 10a3ae7f8..4672ffb8b 100644 --- a/mrp_bom_location/models/mrp_bom.py +++ b/mrp_bom_location/models/mrp_bom.py @@ -24,6 +24,5 @@ class MrpBomLine(models.Model): location_id = fields.Many2one( related='bom_id.location_id', - readonly=True, store=True, ) diff --git a/mrp_bom_location/readme/CONTRIBUTORS.rst b/mrp_bom_location/readme/CONTRIBUTORS.rst new file mode 100644 index 000000000..ec5efe6d3 --- /dev/null +++ b/mrp_bom_location/readme/CONTRIBUTORS.rst @@ -0,0 +1,3 @@ +* Lois Rilo +* Mykhailo Panarin +* Saran Limpajitkutaporn 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/bom_structure.py b/mrp_bom_location/report/bom_structure.py index 91376c274..e541aeb45 100644 --- a/mrp_bom_location/report/bom_structure.py +++ b/mrp_bom_location/report/bom_structure.py @@ -6,11 +6,28 @@ from odoo import api, models class BomStructureReport(models.AbstractModel): - _inherit = 'report.mrp.mrp_bom_structure_report' + _inherit = 'report.mrp.report_bom_structure' @api.model - def _get_child_vals(self, record, level, qty, uom): - res = super(BomStructureReport, self)._get_child_vals( - record, level, qty, uom) - res['location_name'] = record.location_id.complete_name or '' + 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/index.html b/mrp_bom_location/static/description/index.html new file mode 100644 index 000000000..a172d210a --- /dev/null +++ b/mrp_bom_location/static/description/index.html @@ -0,0 +1,433 @@ + + + + + + +MRP BOM Location + + + +
+

MRP BOM Location

+ + +

Beta License: AGPL-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. One 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

+
    +
  • Eficent
  • +
+
+
+

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 index 7cec665a4..026d06431 100644 --- a/mrp_bom_location/views/mrp_view.xml +++ b/mrp_bom_location/views/mrp_view.xml @@ -37,15 +37,15 @@ - + - - mrp.bom.component.tree - mrp_bom_location + + mrp.bom.line.view.form - mrp_bom_location mrp.bom.line - + @@ -53,18 +53,4 @@ - - mrp.bom.line.select - mrp_bom_location - mrp.bom.line - - - - - - - - - - - diff --git a/mrp_bom_location/views/report_mrpbomstructure.xml b/mrp_bom_location/views/report_mrpbomstructure.xml index be2a75a61..ceaf55408 100644 --- a/mrp_bom_location/views/report_mrpbomstructure.xml +++ b/mrp_bom_location/views/report_mrpbomstructure.xml @@ -1,17 +1,29 @@ -