[MIG] stock_picking_report_valued_sale_mrp: Migration to 13.0

This commit is contained in:
david
2021-06-04 11:41:05 +02:00
committed by Carlos Roca
parent 6352365e84
commit c30a567f0f
6 changed files with 23 additions and 7 deletions

View File

@@ -3,7 +3,7 @@
{
"name": "Valued picking linked with MRP Kits",
"summary": "Allow to summarize the picking related with the selled kits",
"version": "12.0.1.0.2",
"version": "13.0.1.0.0",
"development_status": "Beta",
"category": "Warehouse Management",
"website": "https://github.com/OCA/stock-logistics-reporting",

View File

@@ -12,7 +12,11 @@ class StockMove(models.Model):
were manually changed, it could lead to inconsistencies"""
self.ensure_one()
sale_line = self.sale_line_id
if not sale_line or not sale_line.product_id._is_phantom_bom():
if (
not sale_line
or not sale_line.product_id.get_components()
or sale_line.product_id.ids == sale_line.product_id.get_components()
):
return 0
component_demand = sum(
sale_line.move_ids.filtered(

View File

@@ -23,8 +23,11 @@ class StockMoveLine(models.Model):
@api.depends("sale_line")
def _compute_phantom_product_id(self):
"""Relate every line with its kit product"""
self.write({"phantom_product_id": False})
for line in self.filtered(
lambda x: x.sale_line and x.sale_line.product_id._is_phantom_bom()
lambda x: x.sale_line
and x.sale_line.product_id.get_components()
and x.sale_line.product_id.ids != x.sale_line.product_id.get_components()
):
line.phantom_product_id = line.sale_line.product_id
@@ -33,7 +36,11 @@ class StockMoveLine(models.Model):
avoid duplicate the amounts. We also need to recompute the total
amounts according to the corresponding delivered kits"""
super()._compute_sale_order_line_fields()
kit_lines = self.filtered("phantom_product_id")
pickings = self.mapped("picking_id")
kit_lines = pickings.move_line_ids.filtered("phantom_product_id")
pickings.move_line_ids.write(
{"phantom_line": False, "phantom_delivered_qty": 0.0}
)
for sale_line in kit_lines.mapped("sale_line"):
move_lines = kit_lines.filtered(lambda x: x.sale_line == sale_line)
# Deduct the kit quantity from the first component in the picking.

View File

@@ -1,3 +1,4 @@
* `Tecnativa <https://www.tecnativa.com>`_:
* David Vidal
* Carlos Roca

View File

@@ -28,17 +28,17 @@
/>
</xpath>
<xpath
expr="//span[@t-field='move_line.product_id.sudo().description_pickingout']"
expr="//span[@t-field='move_line.move_id.description_picking']"
position="attributes"
>
<attribute name="t-if">not move_line.phantom_line</attribute>
</xpath>
<xpath
expr="//span[@t-field='move_line.product_id.sudo().description_pickingout']"
expr="//span[@t-field='move_line.move_id.description_picking']"
position="before"
>
<span
t-field="move_line.sale_line.product_id.sudo().description_pickingout"
t-esc="move_line.sale_line.product_id.sudo()._get_description(o.picking_type_id)"
t-if="move_line.phantom_line"
/>
</xpath>

View File

@@ -69,3 +69,7 @@ class TestStockPickingValuedMrp(TestStockPickingValued):
self.assertAlmostEqual(self.order_out_picking.amount_untaxed, 149.5)
self.assertAlmostEqual(self.order_out_picking.amount_tax, 14.95)
self.assertAlmostEqual(self.order_out_picking.amount_total, 164.45)
# Run the report to detect hidden errors
self.env.ref("stock.action_report_delivery").render_qweb_html(
self.order_out_picking.ids
)