[MIG] Migrated the module mrp_bom_location to v13.

This commit is contained in:
sudhir-erpharbor
2019-10-11 16:57:21 +05:30
committed by davidborromeo
parent 99e3270b05
commit 12299190ce
7 changed files with 37 additions and 42 deletions

View File

@@ -14,13 +14,13 @@ MRP BOM Location
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html :target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
:alt: License: AGPL-3 :alt: License: AGPL-3
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fmanufacture-lightgray.png?logo=github .. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fmanufacture-lightgray.png?logo=github
:target: https://github.com/OCA/manufacture/tree/12.0/mrp_bom_location :target: https://github.com/OCA/manufacture/tree/13.0/mrp_bom_location
:alt: OCA/manufacture :alt: OCA/manufacture
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png .. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
:target: https://translation.odoo-community.org/projects/manufacture-12-0/manufacture-12-0-mrp_bom_location :target: https://translation.odoo-community.org/projects/manufacture-13-0/manufacture-13-0-mrp_bom_location
:alt: Translate me on Weblate :alt: Translate me on Weblate
.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png .. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png
:target: https://runbot.odoo-community.org/runbot/129/12.0 :target: https://runbot.odoo-community.org/runbot/129/13.0
:alt: Try me on Runbot :alt: Try me on Runbot
|badge1| |badge2| |badge3| |badge4| |badge5| |badge1| |badge2| |badge3| |badge4| |badge5|
@@ -68,6 +68,7 @@ Contributors
* Lois Rilo <lois.rilo@eficent.com> * Lois Rilo <lois.rilo@eficent.com>
* Mykhailo Panarin <m.panarin@mobilunity.com> * Mykhailo Panarin <m.panarin@mobilunity.com>
* Saran Limpajitkutaporn <saranl@ecosoft.co.th> * Saran Limpajitkutaporn <saranl@ecosoft.co.th>
* Sudhir Arya <sudhir@erpharbor.com>
Maintainers Maintainers
~~~~~~~~~~~ ~~~~~~~~~~~
@@ -82,6 +83,6 @@ OCA, or the Odoo Community Association, is a nonprofit organization whose
mission is to support the collaborative development of Odoo features and mission is to support the collaborative development of Odoo features and
promote its widespread use. promote its widespread use.
This module is part of the `OCA/manufacture <https://github.com/OCA/manufacture/tree/12.0/mrp_bom_location>`_ project on GitHub. This module is part of the `OCA/manufacture <https://github.com/OCA/manufacture/tree/13.0/mrp_bom_location>`_ project on GitHub.
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

View File

@@ -3,18 +3,13 @@
{ {
"name": "MRP BOM Location", "name": "MRP BOM Location",
"summary": "Adds location field to Bill of Materials and its components.", "summary": "Adds location field to Bill of Materials and its components.",
"version": "12.0.1.0.1", "version": "13.0.1.0.1",
"category": "Manufacture", "category": "Manufacture",
"website": "https://github.com/OCA/manufacture", "website": "https://github.com/OCA/manufacture",
"author": "Eficent, Odoo Community Association (OCA)", "author": "Eficent, Odoo Community Association (OCA)",
"license": "AGPL-3", "license": "AGPL-3",
"application": False, "application": False,
"depends": [ "depends": ["mrp"],
"mrp", "data": ["views/mrp_view.xml", "views/report_mrpbomstructure.xml"],
], "installable": True,
"data": [
"views/mrp_view.xml",
"views/report_mrpbomstructure.xml",
],
"installable": True
} }

View File

@@ -7,22 +7,15 @@ from odoo import api, fields, models
class MrpBom(models.Model): class MrpBom(models.Model):
_inherit = "mrp.bom" _inherit = "mrp.bom"
location_id = fields.Many2one( location_id = fields.Many2one(string="Location", comodel_name="stock.location")
string='Location',
comodel_name='stock.location',
)
@api.onchange('picking_type_id') @api.onchange("picking_type_id")
def _onchange_picking_type_id(self): def _onchange_picking_type_id(self):
if (self.picking_type_id and if self.picking_type_id and self.picking_type_id.default_location_src_id:
self.picking_type_id.default_location_src_id):
self.location_id = self.picking_type_id.default_location_src_id self.location_id = self.picking_type_id.default_location_src_id
class MrpBomLine(models.Model): class MrpBomLine(models.Model):
_inherit = "mrp.bom.line" _inherit = "mrp.bom.line"
location_id = fields.Many2one( location_id = fields.Many2one(related="bom_id.location_id", store=True)
related='bom_id.location_id',
store=True,
)

View File

@@ -1,3 +1,4 @@
* Lois Rilo <lois.rilo@eficent.com> * Lois Rilo <lois.rilo@eficent.com>
* Mykhailo Panarin <m.panarin@mobilunity.com> * Mykhailo Panarin <m.panarin@mobilunity.com>
* Saran Limpajitkutaporn <saranl@ecosoft.co.th> * Saran Limpajitkutaporn <saranl@ecosoft.co.th>
* Sudhir Arya <sudhir@erpharbor.com>

View File

@@ -6,28 +6,32 @@ from odoo import api, models
class BomStructureReport(models.AbstractModel): class BomStructureReport(models.AbstractModel):
_inherit = 'report.mrp.report_bom_structure' _inherit = "report.mrp.report_bom_structure"
@api.model @api.model
def _get_bom_lines(self, bom, bom_quantity, product, line_id, level): def _get_bom_lines(self, bom, bom_quantity, product, line_id, level):
res = super(BomStructureReport, self)._get_bom_lines( res = super(BomStructureReport, self)._get_bom_lines(
bom, bom_quantity, product, line_id, level) bom, bom_quantity, product, line_id, level
line_ids = self.env['mrp.bom.line'].search([('bom_id', '=', bom.id)]) )
line_ids = self.env["mrp.bom.line"].search([("bom_id", "=", bom.id)])
for line in res[0]: for line in res[0]:
line_id = line_ids.filtered( line_id = line_ids.filtered(
lambda l: l.location_id and l.id == line['line_id']) lambda l: l.location_id and l.id == line["line_id"]
line['location_id'] = line_id.location_id or '' )
line["location_id"] = line_id.location_id or ""
return res return res
@api.model @api.model
def _get_pdf_line(self, bom_id, product_id=False, qty=1, def _get_pdf_line(
child_bom_ids=None, unfolded=False): self, bom_id, product_id=False, qty=1, child_bom_ids=None, unfolded=False
):
res = super(BomStructureReport, self)._get_pdf_line( res = super(BomStructureReport, self)._get_pdf_line(
bom_id, product_id, qty, child_bom_ids, unfolded) 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_ids = self.env["mrp.bom.line"].search([("bom_id", "=", bom_id)])
for line in res["lines"]:
line_id = line_ids.filtered( line_id = line_ids.filtered(
lambda l: l.location_id and lambda l: l.location_id and l.product_id.display_name == line["name"]
l.product_id.display_name == line['name']) )
line['location_name'] = line_id.location_id.complete_name or '' line["location_name"] = line_id.location_id.complete_name or ""
return res return res

View File

@@ -367,7 +367,7 @@ ul.auto-toc {
!! This file is generated by oca-gen-addon-readme !! !! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !! !! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! --> !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
<p><a class="reference external" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external" href="http://www.gnu.org/licenses/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/licence-AGPL--3-blue.png" /></a> <a class="reference external" href="https://github.com/OCA/manufacture/tree/12.0/mrp_bom_location"><img alt="OCA/manufacture" src="https://img.shields.io/badge/github-OCA%2Fmanufacture-lightgray.png?logo=github" /></a> <a class="reference external" href="https://translation.odoo-community.org/projects/manufacture-12-0/manufacture-12-0-mrp_bom_location"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external" href="https://runbot.odoo-community.org/runbot/129/12.0"><img alt="Try me on Runbot" src="https://img.shields.io/badge/runbot-Try%20me-875A7B.png" /></a></p> <p><a class="reference external" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external" href="http://www.gnu.org/licenses/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/licence-AGPL--3-blue.png" /></a> <a class="reference external" href="https://github.com/OCA/manufacture/tree/13.0/mrp_bom_location"><img alt="OCA/manufacture" src="https://img.shields.io/badge/github-OCA%2Fmanufacture-lightgray.png?logo=github" /></a> <a class="reference external" href="https://translation.odoo-community.org/projects/manufacture-13-0/manufacture-13-0-mrp_bom_location"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external" href="https://runbot.odoo-community.org/runbot/129/13.0"><img alt="Try me on Runbot" src="https://img.shields.io/badge/runbot-Try%20me-875A7B.png" /></a></p>
<p>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.</p> <p>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.</p>
<p>The location appears in the BOM Structure Report.</p> <p>The location appears in the BOM Structure Report.</p>
<p><strong>Table of contents</strong></p> <p><strong>Table of contents</strong></p>
@@ -415,6 +415,7 @@ If you spotted it first, help us smashing it by providing a detailed and welcome
<li>Lois Rilo &lt;<a class="reference external" href="mailto:lois.rilo&#64;eficent.com">lois.rilo&#64;eficent.com</a>&gt;</li> <li>Lois Rilo &lt;<a class="reference external" href="mailto:lois.rilo&#64;eficent.com">lois.rilo&#64;eficent.com</a>&gt;</li>
<li>Mykhailo Panarin &lt;<a class="reference external" href="mailto:m.panarin&#64;mobilunity.com">m.panarin&#64;mobilunity.com</a>&gt;</li> <li>Mykhailo Panarin &lt;<a class="reference external" href="mailto:m.panarin&#64;mobilunity.com">m.panarin&#64;mobilunity.com</a>&gt;</li>
<li>Saran Limpajitkutaporn &lt;<a class="reference external" href="mailto:saranl&#64;ecosoft.co.th">saranl&#64;ecosoft.co.th</a>&gt;</li> <li>Saran Limpajitkutaporn &lt;<a class="reference external" href="mailto:saranl&#64;ecosoft.co.th">saranl&#64;ecosoft.co.th</a>&gt;</li>
<li>Sudhir Arya &lt;<a class="reference external" href="mailto:sudhir&#64;erpharbor.com">sudhir&#64;erpharbor.com</a>&gt;</li>
</ul> </ul>
</div> </div>
<div class="section" id="maintainers"> <div class="section" id="maintainers">
@@ -424,7 +425,7 @@ If you spotted it first, help us smashing it by providing a detailed and welcome
<p>OCA, or the Odoo Community Association, is a nonprofit organization whose <p>OCA, or the Odoo Community Association, is a nonprofit organization whose
mission is to support the collaborative development of Odoo features and mission is to support the collaborative development of Odoo features and
promote its widespread use.</p> promote its widespread use.</p>
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/manufacture/tree/12.0/mrp_bom_location">OCA/manufacture</a> project on GitHub.</p> <p>This module is part of the <a class="reference external" href="https://github.com/OCA/manufacture/tree/13.0/mrp_bom_location">OCA/manufacture</a> project on GitHub.</p>
<p>You are welcome to contribute. To learn how please visit <a class="reference external" href="https://odoo-community.org/page/Contribute">https://odoo-community.org/page/Contribute</a>.</p> <p>You are welcome to contribute. To learn how please visit <a class="reference external" href="https://odoo-community.org/page/Contribute">https://odoo-community.org/page/Contribute</a>.</p>
</div> </div>
</div> </div>

View File

@@ -2,10 +2,10 @@
<odoo> <odoo>
<template id="report_mrpbomstructure_location" inherit_id="mrp.report_mrp_bom"> <template id="report_mrpbomstructure_location" inherit_id="mrp.report_mrp_bom">
<xpath expr="//thead/tr/th[last()]" position="before"> <xpath expr="//thead/tr/th[last()]" position="before">
<th t-if="data['bom'].location_id" class="o_mrp_has_attachments" title="Location of the product">Location</th> <th t-if="data['bom'].location_id" class="o_mrp_bom_cost text-right" title="Location of the product">Location</th>
</xpath> </xpath>
<xpath expr="//tbody/tr/td[last()]" position="before"> <xpath expr="//tbody/tr/td[last()]" position="before">
<td t-if="data['bom'].location_id"> <td t-if="data['bom'].location_id" class="text-right">
<span><a href="#" t-if="data['report_type'] == 'html'" t-att-data-res-id="data['bom'].location_id.id" t-att-data-model="'stock.location'" class="o_mrp_bom_action"><t t-esc="data['bom'].location_id.complete_name"/></a><t t-else="" t-esc="data['bom'].location_id.complete_name"/></span> <span><a href="#" t-if="data['report_type'] == 'html'" t-att-data-res-id="data['bom'].location_id.id" t-att-data-model="'stock.location'" class="o_mrp_bom_action"><t t-esc="data['bom'].location_id.complete_name"/></a><t t-else="" t-esc="data['bom'].location_id.complete_name"/></span>
</td> </td>
</xpath> </xpath>
@@ -24,7 +24,7 @@
<template id="report_mrp_bom_pdf_line" inherit_id="mrp.report_mrp_bom_pdf_line"> <template id="report_mrp_bom_pdf_line" inherit_id="mrp.report_mrp_bom_pdf_line">
<xpath expr="//tr" position="inside"> <xpath expr="//tr" position="inside">
<td t-if="l.get('location_name', False)"> <td t-if="l.get('location_name', False)" class="text-right">
<span t-esc="l['location_name']"/> <span t-esc="l['location_name']"/>
</td> </td>
<td t-else=""/> <td t-else=""/>