diff --git a/mrp_bom_location/README.rst b/mrp_bom_location/README.rst new file mode 100644 index 000000000..2179a654b --- /dev/null +++ b/mrp_bom_location/README.rst @@ -0,0 +1,69 @@ +.. 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. + +The location appears in the BOM Structure Report. + + +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". +#. 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. + +Credits +======= + +Images +------ + +* Odoo Community Association: `Icon `_. + +Contributors +------------ + +* Lois Rilo +* Mykhailo Panarin + +Do not contact contributors directly about support or help with technical +issues. + +Maintainer +---------- + +.. 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. diff --git a/mrp_bom_location/__init__.py b/mrp_bom_location/__init__.py new file mode 100644 index 000000000..347b23ce7 --- /dev/null +++ b/mrp_bom_location/__init__.py @@ -0,0 +1,5 @@ +# Copyright 2017 Eficent Business and IT Consulting Services S.L. +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +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..6aa0b696b --- /dev/null +++ b/mrp_bom_location/__manifest__.py @@ -0,0 +1,19 @@ +# Copyright 2017 Eficent Business and IT Consulting Services S.L. +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). +{ + "name": "MRP BOM Location", + "summary": "Adds location field to Bill of Materials and its components.", + "version": "11.0.1.0.0", + "category": "Manufacture", + "website": "https://github.com/OCA/manufacture", + "author": "Eficent, Odoo Community Association (OCA)", + "license": "AGPL-3", + "application": False, + "depends": [ + "mrp", + ], + "data": [ + "views/mrp_view.xml", + "views/report_mrpbomstructure.xml", + ], +} diff --git a/mrp_bom_location/models/__init__.py b/mrp_bom_location/models/__init__.py new file mode 100644 index 000000000..a06bc71a4 --- /dev/null +++ b/mrp_bom_location/models/__init__.py @@ -0,0 +1,4 @@ +# Copyright 2017 Eficent Business and IT Consulting Services S.L. +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +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..10a3ae7f8 --- /dev/null +++ b/mrp_bom_location/models/mrp_bom.py @@ -0,0 +1,29 @@ +# Copyright 2017 Eficent Business and IT Consulting Services S.L. +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +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', + readonly=True, + store=True, + ) diff --git a/mrp_bom_location/report/__init__.py b/mrp_bom_location/report/__init__.py new file mode 100644 index 000000000..9956baed8 --- /dev/null +++ b/mrp_bom_location/report/__init__.py @@ -0,0 +1,4 @@ +# Copyright 2017 Eficent Business and IT Consulting Services S.L. +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +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..91376c274 --- /dev/null +++ b/mrp_bom_location/report/bom_structure.py @@ -0,0 +1,16 @@ +# © 2017 Eficent Business and IT Consulting Services S.L. +# (http://www.eficent.com) +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). + +from odoo import api, models + + +class BomStructureReport(models.AbstractModel): + _inherit = 'report.mrp.mrp_bom_structure_report' + + @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 '' + 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/views/mrp_view.xml b/mrp_bom_location/views/mrp_view.xml new file mode 100644 index 000000000..7cec665a4 --- /dev/null +++ b/mrp_bom_location/views/mrp_view.xml @@ -0,0 +1,70 @@ + + + + + + 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.component.tree - mrp_bom_location + mrp.bom.line + + + + + + + + + + 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 new file mode 100644 index 000000000..be2a75a61 --- /dev/null +++ b/mrp_bom_location/views/report_mrpbomstructure.xml @@ -0,0 +1,20 @@ + + + +