[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
: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/mrp_bom_location
: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-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
.. |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
|badge1| |badge2| |badge3| |badge4| |badge5|
@@ -68,6 +68,7 @@ Contributors
* Lois Rilo <lois.rilo@eficent.com>
* Mykhailo Panarin <m.panarin@mobilunity.com>
* Saran Limpajitkutaporn <saranl@ecosoft.co.th>
* Sudhir Arya <sudhir@erpharbor.com>
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
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.

View File

@@ -3,18 +3,13 @@
{
"name": "MRP BOM Location",
"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",
"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",
],
"installable": True
"depends": ["mrp"],
"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):
_inherit = "mrp.bom"
location_id = fields.Many2one(
string='Location',
comodel_name='stock.location',
)
location_id = fields.Many2one(string="Location", comodel_name="stock.location")
@api.onchange('picking_type_id')
@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):
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,
)
location_id = fields.Many2one(related="bom_id.location_id", store=True)

View File

@@ -1,3 +1,4 @@
* Lois Rilo <lois.rilo@eficent.com>
* Mykhailo Panarin <m.panarin@mobilunity.com>
* 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):
_inherit = 'report.mrp.report_bom_structure'
_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)])
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 ''
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):
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']:
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 ''
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

View File

@@ -367,7 +367,7 @@ ul.auto-toc {
!! This file is generated by oca-gen-addon-readme !!
!! 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>The location appears in the BOM Structure Report.</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>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>Sudhir Arya &lt;<a class="reference external" href="mailto:sudhir&#64;erpharbor.com">sudhir&#64;erpharbor.com</a>&gt;</li>
</ul>
</div>
<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
mission is to support the collaborative development of Odoo features and
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>
</div>
</div>

View File

@@ -2,10 +2,10 @@
<odoo>
<template id="report_mrpbomstructure_location" inherit_id="mrp.report_mrp_bom">
<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 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>
</td>
</xpath>
@@ -24,7 +24,7 @@
<template id="report_mrp_bom_pdf_line" inherit_id="mrp.report_mrp_bom_pdf_line">
<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']"/>
</td>
<td t-else=""/>