mirror of
https://github.com/OCA/manufacture.git
synced 2025-01-28 16:37:15 +02:00
[WIP][FIX] mrp_bom_location: fix migration
This commit is contained in:
committed by
SergiCForgeFlow
parent
d66d57c35c
commit
ce85ca8070
@@ -11,5 +11,10 @@
|
|||||||
"application": False,
|
"application": False,
|
||||||
"depends": ["mrp"],
|
"depends": ["mrp"],
|
||||||
"data": ["views/mrp_view.xml", "views/report_mrpbomstructure.xml"],
|
"data": ["views/mrp_view.xml", "views/report_mrpbomstructure.xml"],
|
||||||
|
"assets": {
|
||||||
|
"web.assets_backend": [
|
||||||
|
"mrp_bom_location/static/src/xml/mrp_bom_overview_location.xml",
|
||||||
|
],
|
||||||
|
},
|
||||||
"installable": True,
|
"installable": True,
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,24 +8,75 @@ 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_data(
|
||||||
res = super(BomStructureReport, self)._get_bom_lines(
|
self,
|
||||||
bom, bom_quantity, product, line_id, level
|
bom,
|
||||||
|
warehouse,
|
||||||
|
product=False,
|
||||||
|
line_qty=False,
|
||||||
|
bom_line=False,
|
||||||
|
level=0,
|
||||||
|
parent_bom=False,
|
||||||
|
index=0,
|
||||||
|
product_info=False,
|
||||||
|
ignore_stock=False,
|
||||||
|
):
|
||||||
|
res = super(BomStructureReport, self)._get_bom_data(
|
||||||
|
bom,
|
||||||
|
warehouse,
|
||||||
|
product=product,
|
||||||
|
line_qty=line_qty,
|
||||||
|
bom_line=bom_line,
|
||||||
|
level=level,
|
||||||
|
parent_bom=parent_bom,
|
||||||
|
index=index,
|
||||||
|
product_info=product_info,
|
||||||
|
ignore_stock=ignore_stock,
|
||||||
)
|
)
|
||||||
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["components"]:
|
||||||
line_id = line_ids.filtered(
|
bom_line = line_ids.filtered(
|
||||||
lambda l: l.location_id and l.id == line["line_id"]
|
lambda l: l.location_id and l.product_id == line["product_id"]
|
||||||
)
|
)
|
||||||
line["location_id"] = line_id.location_id or ""
|
line["location_id"] = bom_line.location_id or ""
|
||||||
|
if parent_bom and parent_bom.location_id.complete_name:
|
||||||
|
res["location"] = parent_bom.location_id.complete_name
|
||||||
|
else:
|
||||||
|
res["location"] = bom.location_id.complete_name or ""
|
||||||
|
return res
|
||||||
|
|
||||||
|
@api.model
|
||||||
|
def _get_component_data(
|
||||||
|
self,
|
||||||
|
parent_bom,
|
||||||
|
warehouse,
|
||||||
|
bom_line,
|
||||||
|
line_quantity,
|
||||||
|
level,
|
||||||
|
index,
|
||||||
|
product_info,
|
||||||
|
ignore_stock=False,
|
||||||
|
):
|
||||||
|
res = super(BomStructureReport, self)._get_component_data(
|
||||||
|
parent_bom,
|
||||||
|
warehouse,
|
||||||
|
bom_line,
|
||||||
|
line_quantity,
|
||||||
|
level,
|
||||||
|
index,
|
||||||
|
product_info,
|
||||||
|
ignore_stock=ignore_stock,
|
||||||
|
)
|
||||||
|
# line_ids = self.env["mrp.bom.line"].search([("bom_id", "=", parent_bom.id)])
|
||||||
|
res["location"] = parent_bom.location_id.complete_name or ""
|
||||||
return res
|
return res
|
||||||
|
|
||||||
@api.model
|
@api.model
|
||||||
def _get_pdf_line(
|
def _get_pdf_line(
|
||||||
self, bom_id, product_id=False, qty=1, child_bom_ids=None, unfolded=False
|
self, bom_id, product_id=False, qty=1, unfolded_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, unfolded_ids, unfolded
|
||||||
)
|
)
|
||||||
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["lines"]:
|
for line in res["lines"]:
|
||||||
|
|||||||
@@ -0,0 +1,25 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8" ?>
|
||||||
|
<templates id="template" xml:space="preserve">
|
||||||
|
<t
|
||||||
|
t-name="mrp_bom_location.BomOverviewTable"
|
||||||
|
t-inherit="mrp.BomOverviewTable"
|
||||||
|
t-inherit-mode="extension"
|
||||||
|
owl="1"
|
||||||
|
>
|
||||||
|
<xpath expr="//thead/tr/th[last()-1]" position="after">
|
||||||
|
<th t-if="data.location">Location</th>
|
||||||
|
</xpath>
|
||||||
|
</t>
|
||||||
|
<t
|
||||||
|
t-name="mrp_bom_location.BomOverviewLine"
|
||||||
|
t-inherit="mrp.BomOverviewLine"
|
||||||
|
t-inherit-mode="extension"
|
||||||
|
owl="1"
|
||||||
|
>
|
||||||
|
<xpath expr="//td[last()-1]" position="after">
|
||||||
|
<td t-if="data.location">
|
||||||
|
<t t-esc="data.location" />
|
||||||
|
</td>
|
||||||
|
</xpath>
|
||||||
|
</t>
|
||||||
|
</templates>
|
||||||
@@ -1,25 +1,25 @@
|
|||||||
<?xml version="1.0" encoding="utf-8" ?>
|
<?xml version="1.0" encoding="utf-8" ?>
|
||||||
<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[1]" position="after">
|
<xpath expr="//thead/tr/th[last()-1]" position="after">
|
||||||
<th
|
<th
|
||||||
t-if="data['bom'].location_id"
|
t-if="data['bom'].location_id"
|
||||||
class="o_mrp_bom_cost text-right"
|
class="o_mrp_bom_cost text-right"
|
||||||
title="Location of the product"
|
title="Location of the product"
|
||||||
>Location</th>
|
>Location</th>
|
||||||
</xpath>
|
</xpath>
|
||||||
<xpath expr="//tbody/tr/td[1]" position="after">
|
<xpath expr="//tbody/tr/td[last()-1]" position="after">
|
||||||
<td class="text-end" t-esc="data['bom'].location_id.complete_name" />
|
<td class="text-end" t-esc="data['bom'].location_id.complete_name" />
|
||||||
</xpath>
|
</xpath>
|
||||||
<xpath expr="//td[@name='td_mrp_bom_f']" position="after">
|
<xpath expr="//tbody/tr[last()]/td[last()-1]" position="after">
|
||||||
<td t-if="data['bom'].location_id" />
|
<td t-if="data['bom'].location_id" />
|
||||||
</xpath>
|
</xpath>
|
||||||
<xpath expr="//td[@name='td_mrp_bom_byproducts_f']" position="after">
|
<xpath expr="//tbody/t[last()]/tr/td[last()-1]" position="after">
|
||||||
<td t-if="data['bom'].location_id" />
|
<td t-if="data['bom'].location_id" />
|
||||||
</xpath>
|
</xpath>
|
||||||
</template>
|
</template>
|
||||||
<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="//td[1]" position="after">
|
<xpath expr="//td[last()-1]" position="after">
|
||||||
<td t-if="data['bom'].location_id" class="text-right">
|
<td t-if="data['bom'].location_id" class="text-right">
|
||||||
<span t-esc="l['location_name']" />
|
<span t-esc="l['location_name']" />
|
||||||
</td>
|
</td>
|
||||||
|
|||||||
Reference in New Issue
Block a user