Skip to content

Commit c285043

Browse files
committed
[MIG] stock_picking_report_valued_sale_mrp: Migration to 18.0
1 parent c4af587 commit c285043

File tree

4 files changed

+18
-36
lines changed

4 files changed

+18
-36
lines changed

stock_picking_report_valued_sale_mrp/__manifest__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
{
44
"name": "Valued picking linked with MRP Kits",
55
"summary": "Allow to summarize the picking related with the selled kits",
6-
"version": "16.0.1.0.0",
6+
"version": "18.0.1.0.0",
77
"development_status": "Beta",
88
"category": "Warehouse Management",
99
"website": "https://github.com/OCA/stock-logistics-reporting",

stock_picking_report_valued_sale_mrp/models/stock_move_line.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ class StockMoveLine(models.Model):
1111
compute="_compute_phantom_product_id",
1212
compute_sudo=True,
1313
string="Product Kit",
14-
readonly=True,
1514
)
1615
phantom_line = fields.Boolean(
1716
compute="_compute_sale_order_line_fields",
@@ -44,7 +43,7 @@ def _compute_sale_order_line_fields(self):
4443
)
4544
for picking in pickings:
4645
self.filtered(
47-
lambda x: x.picking_id == picking
46+
lambda x, picking=picking: x.picking_id == picking
4847
)._compute_sale_order_line_fields_by_picking()
4948
return res
5049

@@ -54,7 +53,9 @@ def _compute_sale_order_line_fields_by_picking(self):
5453
"""
5554
kit_lines = self.filtered("phantom_product_id")
5655
for sale_line in kit_lines.mapped("sale_line"):
57-
move_lines = kit_lines.filtered(lambda x: x.sale_line == sale_line)
56+
move_lines = kit_lines.filtered(
57+
lambda x, sale_line=sale_line: x.sale_line == sale_line
58+
)
5859
# Deduce the kit quantity from the first component in the picking.
5960
# If the the kit is partially delivered, this could lead to an
6061
# unacurate value.
@@ -72,8 +73,9 @@ def _compute_sale_order_line_fields_by_picking(self):
7273
components_per_kit = phantom_line.move_id._get_components_per_kit()
7374
phantom_line_qty_done = sum(
7475
move_lines.filtered(
75-
lambda x: x.product_id == phantom_line.product_id
76-
).mapped("qty_done")
76+
lambda x, phantom_line=phantom_line: x.product_id
77+
== phantom_line.product_id
78+
).mapped("quantity")
7779
)
7880
quantity = phantom_line_qty_done / components_per_kit
7981
taxes = phantom_line.sale_tax_id.compute_all(

stock_picking_report_valued_sale_mrp/report/stock_picking_report_valued.xml

Lines changed: 6 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -22,32 +22,12 @@
2222
id="valued_mrp_report_picking"
2323
inherit_id="stock_picking_report_valued.valued_report_picking"
2424
>
25-
<!-- show only one row for kit products -->
26-
<xpath expr="//tr[@t-foreach='package_move_lines']" position="before">
25+
<!-- Show only one row for kit products -->
26+
<xpath expr="//table[@name='stock_move_line_table']/tbody" position="before">
2727
<t t-if="o.valued and o.sale_id and o.move_line_ids and is_outgoing">
2828
<t
29-
t-set="package_move_lines"
30-
t-value="package_move_lines.filtered(lambda l: not l.phantom_product_id or l.phantom_line)"
31-
/>
32-
</t>
33-
</xpath>
34-
<xpath expr="//tr[@t-foreach='move_lines']" position="before">
35-
<t t-if="o.valued and o.sale_id and o.move_line_ids and is_outgoing">
36-
<t
37-
t-set="move_lines"
38-
t-value="move_lines.filtered(lambda l: not l.phantom_product_id or l.phantom_line)"
39-
/>
40-
</t>
41-
</xpath>
42-
<xpath expr="//tr[@t-foreach='o.move_line_ids']" position="attributes">
43-
<attribute name="t-foreach">has_no_packages_move_lines</attribute>
44-
</xpath>
45-
<xpath expr="//tr[@t-foreach='has_no_packages_move_lines']" position="before">
46-
<t t-set="has_no_packages_move_lines" t-value="o.move_line_ids" />
47-
<t t-if="o.valued and o.sale_id and o.move_line_ids and is_outgoing">
48-
<t
49-
t-set="has_no_packages_move_lines"
50-
t-value="has_no_packages_move_lines.filtered(lambda l: not l.phantom_product_id or l.phantom_line)"
29+
t-set="lines"
30+
t-value="lines.filtered(lambda l: not l.phantom_product_id or l.phantom_line)"
5131
/>
5232
</t>
5333
</xpath>
@@ -69,10 +49,10 @@
6949
<xpath expr="//span[@t-field='move_line.product_id']" position="before">
7050
<span t-field="move_line.sale_line.product_id" t-if="can_display_phantom" />
7151
</xpath>
72-
<xpath expr="//td[@name='move_line_lot_qty_done']" position="attributes">
52+
<xpath expr="//td[@name='move_line_lot_quantity']" position="attributes">
7353
<attribute name="t-if">not can_display_phantom</attribute>
7454
</xpath>
75-
<xpath expr="//td[@name='move_line_lot_qty_done']" position="after">
55+
<xpath expr="//td[@name='move_line_lot_quantity']" position="after">
7656
<td class="text-center" t-if="can_display_phantom">
7757
<span t-field="move_line.phantom_delivered_qty" />
7858
<span t-field="move_line.sale_line.product_uom" />

stock_picking_report_valued_sale_mrp/tests/test_stock_picking_report_valued_mrp.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,10 @@ def setUpClass(cls):
1818
{"name": "Product test 1", "type": "consu"}
1919
)
2020
cls.product_kit_comp_1 = cls.product_product.create(
21-
{"name": "Product Component 1", "type": "product"}
21+
{"name": "Product Component 1", "type": "consu"}
2222
)
2323
cls.product_kit_comp_2 = cls.product_product.create(
24-
{"name": "Product Component 2", "type": "product"}
24+
{"name": "Product Component 2", "type": "consu"}
2525
)
2626
cls.bom = cls.env["mrp.bom"].create(
2727
{
@@ -43,7 +43,7 @@ def setUpClass(cls):
4343
}
4444
)
4545
cls.product_2 = cls.product_product.create(
46-
{"name": "Product test 2", "type": "product"}
46+
{"name": "Product test 2", "type": "consu"}
4747
)
4848
order_form = Form(cls.env["sale.order"])
4949
order_form.partner_id = cls.partner
@@ -64,7 +64,7 @@ def setUpClass(cls):
6464

6565
def test_01_picking_confirmed(self):
6666
for line in self.order_out_picking.move_ids:
67-
line.quantity_done = line.product_uom_qty
67+
line.quantity = line.product_uom_qty
6868
self.order_out_picking.button_validate()
6969
self.assertAlmostEqual(self.order_out_picking.amount_untaxed, 149.5)
7070
self.assertAlmostEqual(self.order_out_picking.amount_tax, 14.95)

0 commit comments

Comments
 (0)