Skip to content

Commit 20cdb90

Browse files
[MIG] stock_picking_report_undelivered_product: Migration to 18.0
TT54343
1 parent 6daeef9 commit 20cdb90

File tree

10 files changed

+107
-176
lines changed

10 files changed

+107
-176
lines changed

stock_picking_report_undelivered_product/README.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ Contributors
8787

8888
- Sergio Teruel <[email protected]>
8989
- Carlos Dauden <[email protected]>
90+
- Juan Carlos Oñate <[email protected]>
9091

9192
Maintainers
9293
-----------

stock_picking_report_undelivered_product/__manifest__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
{
55
"name": "Stock picking report undelivered products",
66
"summary": "Display on picking report delivery slip undelivered products",
7-
"version": "15.0.1.0.0",
7+
"version": "18.0.1.0.0",
88
"author": "Tecnativa,Odoo Community Association (OCA)",
99
"website": "https://github.com/OCA/stock-logistics-reporting",
1010
"category": "Warehouse",
Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
from . import product_template
22
from . import res_config_settings
33
from . import res_partner
4-
from . import stock_move
54
from . import stock_move_line

stock_picking_report_undelivered_product/models/stock_move.py

Lines changed: 0 additions & 20 deletions
This file was deleted.

stock_picking_report_undelivered_product/models/stock_move_line.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ def _get_aggregated_product_quantities(self, **kwargs):
1414
aggregated_move_lines = super()._get_aggregated_product_quantities(**kwargs)
1515
keys_to_remove = set()
1616
for aggregated_move_line in aggregated_move_lines:
17-
if not aggregated_move_lines[aggregated_move_line]["qty_done"]:
17+
if not aggregated_move_lines[aggregated_move_line]["quantity"]:
1818
keys_to_remove.add(aggregated_move_line)
1919
# To avoid change dict size on iteration
2020
for key_to_remmove in keys_to_remove:

stock_picking_report_undelivered_product/readme/CONTRIBUTORS.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@
22

33
> - Sergio Teruel \<<[email protected]>\>
44
> - Carlos Dauden \<<[email protected]>\>
5+
> - Juan Carlos Oñate \<<[email protected]>\>

stock_picking_report_undelivered_product/static/description/index.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -435,6 +435,7 @@ <h2><a class="toc-backref" href="#toc-entry-5">Contributors</a></h2>
435435
<ul class="simple">
436436
<li>Sergio Teruel &lt;<a class="reference external" href="mailto:sergio.teruel&#64;tecnativa.com">sergio.teruel&#64;tecnativa.com</a>&gt;</li>
437437
<li>Carlos Dauden &lt;<a class="reference external" href="mailto:carlos.dauden&#64;tecnativa.com">carlos.dauden&#64;tecnativa.com</a>&gt;</li>
438+
<li>Juan Carlos Oñate &lt;<a class="reference external" href="mailto:juancarlos.onate&#64;tecnativa.com">juancarlos.onate&#64;tecnativa.com</a>&gt;</li>
438439
</ul>
439440
</blockquote>
440441
</li>

stock_picking_report_undelivered_product/tests/test_stock_picking_report_undelivered_product.py

Lines changed: 35 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
# Copyright 2020 Sergio Teruel - Tecnativa <[email protected]>
22
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
3-
from odoo.tests import common
4-
from odoo.tests.common import Form
3+
from odoo.tests import Form, common
54

65

76
class TestStockPickingReportUndeliveredProduct(common.TransactionCase):
@@ -31,21 +30,24 @@ def setUp(self):
3130
{
3231
"name": "Test product undelivered display",
3332
"display_undelivered_in_picking": True,
34-
"type": "product",
33+
"type": "consu",
34+
"is_storable": True,
3535
}
3636
)
3737
self.product_no_display = self.ProductProduct.create(
3838
{
3939
"name": "Test product undelivered no display",
4040
"display_undelivered_in_picking": False,
41-
"type": "product",
41+
"type": "consu",
42+
"is_storable": True,
4243
}
4344
)
4445
self.product_no_display_wo_stock = self.ProductProduct.create(
4546
{
4647
"name": "Test product undelivered no display without stock",
4748
"display_undelivered_in_picking": False,
48-
"type": "product",
49+
"type": "consu",
50+
"is_storable": True,
4951
}
5052
)
5153
self.StockQuant.create(
@@ -83,57 +85,53 @@ def test_displayed_customer(self):
8385
picking = self._create_picking(self.partner_display)
8486
picking.action_confirm()
8587
picking.action_assign()
86-
picking.move_line_ids.qty_done = 10.00
88+
picking.move_line_ids.quantity = 10.00
8789
self._transfer_picking_no_backorder(picking)
88-
res = (
89-
self.env["ir.actions.report"]
90-
._get_report_from_name("stock.report_deliveryslip")
91-
._render_qweb_html(picking.ids)
90+
res = self.env["ir.actions.report"]._render_qweb_html(
91+
"stock.report_deliveryslip", picking.ids
9292
)
93-
self.assertIn("undelivered_product", str(res[0]))
93+
self.assertIn("Remaining quantities not yet delivered", str(res[0]))
9494

9595
def test_no_displayed_customer(self):
9696
picking = self._create_picking(self.partner_no_display)
9797
picking.action_confirm()
9898
picking.action_assign()
99-
picking.move_line_ids.qty_done = 10.00
99+
picking.move_line_ids.quantity = 10.00
100100
self._transfer_picking_no_backorder(picking)
101-
res = (
102-
self.env["ir.actions.report"]
103-
._get_report_from_name("stock.report_deliveryslip")
104-
._render_qweb_html(picking.ids)
101+
res = self.env["ir.actions.report"]._render_qweb_html(
102+
"stock.report_deliveryslip", picking.ids
105103
)
106-
self.assertNotIn("undelivered_product", str(res[0]))
104+
self.assertNotIn("Remaining quantities not yet delivered", str(res[0]))
107105

108106
def test_no_displayed_product(self):
109107
picking = self._create_picking(self.partner_display)
110-
picking.move_lines.filtered(
111-
lambda l: l.product_id == self.product_display
108+
picking.move_ids.filtered(
109+
lambda move_line: move_line.product_id == self.product_display
112110
).unlink()
113111
picking.action_confirm()
114112
picking.action_assign()
115-
picking.move_line_ids.qty_done = 10.00
113+
picking.move_line_ids.quantity = 10.00
116114
self._transfer_picking_no_backorder(picking)
117-
res = (
118-
self.env["ir.actions.report"]
119-
._get_report_from_name("stock.report_deliveryslip")
120-
._render_qweb_html(picking.ids)
115+
res = self.env["ir.actions.report"]._render_qweb_html(
116+
"stock.report_deliveryslip", picking.ids
121117
)
122-
self.assertNotIn("undelivered_product", str(res[0]))
118+
self.assertNotIn("Remaining quantities not yet delivered", str(res[0]))
123119

124120
def test_picking_report_method(self):
125121
product = self.ProductProduct.create(
126122
{
127123
"name": "test01",
128124
"display_undelivered_in_picking": True,
129-
"type": "product",
125+
"type": "consu",
126+
"is_storable": True,
130127
}
131128
)
132129
product2 = self.ProductProduct.create(
133130
{
134131
"name": "test02",
135132
"display_undelivered_in_picking": True,
136-
"type": "product",
133+
"type": "consu",
134+
"is_storable": True,
137135
}
138136
)
139137
self.StockQuant.create(
@@ -156,45 +154,37 @@ def test_picking_report_method(self):
156154

157155
picking.action_confirm()
158156
picking.action_assign()
159-
picking.move_line_ids.qty_done = 10.00
157+
picking.move_line_ids.quantity = 10.00
160158
self._transfer_picking_no_backorder(picking)
161159

162160
# Empty setting method field
163-
picking.company_id.undelivered_product_slip_report_method = False
164-
res = (
165-
self.env["ir.actions.report"]
166-
._get_report_from_name("stock.report_deliveryslip")
167-
._render_qweb_html(picking.ids)
161+
picking.company_id.undelivered_product_slip_report_method = "all"
162+
res = self.env["ir.actions.report"]._render_qweb_html(
163+
"stock.report_deliveryslip", picking.ids
168164
)
169165
self.assertIn("test02", str(res[0]))
170166

171167
# Print all undelivered lines, partial and completely lines
172168
picking.company_id.undelivered_product_slip_report_method = "all"
173-
res = (
174-
self.env["ir.actions.report"]
175-
._get_report_from_name("stock.report_deliveryslip")
176-
._render_qweb_html(picking.ids)
169+
res = self.env["ir.actions.report"]._render_qweb_html(
170+
"stock.report_deliveryslip", picking.ids
177171
)
178172
self.assertIn("test02", str(res[0]))
179173

180174
# Print only partial undelivered lines
181175
picking.company_id.undelivered_product_slip_report_method = (
182176
"partially_undelivered"
183177
)
184-
res = (
185-
self.env["ir.actions.report"]
186-
._get_report_from_name("stock.report_deliveryslip")
187-
._render_qweb_html(picking.ids)
178+
res = self.env["ir.actions.report"]._render_qweb_html(
179+
"stock.report_deliveryslip", picking.ids
188180
)
189181
self.assertNotIn("test02", str(res[0]))
190182

191183
# Print only completely undelivered lines
192184
picking.company_id.undelivered_product_slip_report_method = (
193185
"completely_undelivered"
194186
)
195-
res = (
196-
self.env["ir.actions.report"]
197-
._get_report_from_name("stock.report_deliveryslip")
198-
._render_qweb_html(picking.ids)
187+
res = self.env["ir.actions.report"]._render_qweb_html(
188+
"stock.report_deliveryslip", picking.ids
199189
)
200190
self.assertNotIn("partially_undelivered_line", str(res[0]))
Lines changed: 44 additions & 83 deletions
Original file line numberDiff line numberDiff line change
@@ -1,95 +1,56 @@
1-
<?xml version="1.0" encoding="utf-8" ?>
21
<odoo>
3-
<template id="undeliverd_product">
4-
<t t-if="o.partner_id.display_undelivered_in_picking and o.state == 'done'">
5-
<!-- Get stock moves from backorder according to setting values -->
6-
<t
7-
t-if="not o.company_id.undelivered_product_slip_report_method or o.company_id.undelivered_product_slip_report_method == 'all'"
8-
>
2+
<template
3+
id="undeliverd_product"
4+
inherit_id="stock.report_delivery_document"
5+
priority="200"
6+
>
7+
<xpath expr="//*[@t-set='backorders']" position="replace">
8+
<t t-if="o.partner_id.display_undelivered_in_picking and o.state == 'done'">
99
<t
10-
t-set="undelivered_moves"
11-
t-value="o.mapped('move_lines').filtered(lambda l: l.quantity_done == 0.0 and l.state == 'cancel' and l.product_id.display_undelivered_in_picking)"
10+
t-set="all_moves"
11+
t-value="o.mapped('move_ids') + o.mapped('backorder_ids').mapped('move_ids')"
1212
/>
13-
</t>
14-
<t
15-
t-if="o.company_id.undelivered_product_slip_report_method == 'partially_undelivered'"
16-
>
13+
<t t-if="o.company_id.undelivered_product_slip_report_method == 'all'">
14+
<t
15+
t-set="undelivered_moves"
16+
t-value="all_moves.filtered(lambda l: (l.product_uom_qty - l.quantity) > 0.0 and l.product_id.display_undelivered_in_picking)"
17+
/>
18+
</t>
1719
<t
18-
t-set="undelivered_moves"
19-
t-value="o.mapped('move_lines').filtered(lambda l: l.state == 'cancel' and l.product_id.display_undelivered_in_picking and l.splitted_stock_move_orig_id)"
20-
/>
21-
</t>
22-
<t
23-
t-if="o.company_id.undelivered_product_slip_report_method == 'completely_undelivered'"
24-
>
20+
t-if="o.company_id.undelivered_product_slip_report_method == 'partially_undelivered'"
21+
>
22+
<t
23+
t-set="undelivered_moves"
24+
t-value="all_moves.filtered(lambda l: l.state != 'cancel' and (l.product_uom_qty - l.quantity) > 0.0 and (l.product_uom_qty - l.quantity) != l.product_uom_qty and l.product_id.display_undelivered_in_picking)"
25+
/>
26+
</t>
2527
<t
26-
t-set="undelivered_moves"
27-
t-value="o.mapped('move_lines').filtered(lambda l: l.state == 'cancel' and l.product_id.display_undelivered_in_picking and not l.splitted_stock_move_orig_id)"
28-
/>
29-
</t>
30-
<table
31-
t-if="undelivered_moves"
32-
class="table table-sm table-bordered mt0"
33-
id="undelivered_product"
34-
>
35-
<thead>
36-
<tr>
37-
<th colspan="7">
38-
<strong>Remaining products (not delivered yet)</strong>
39-
</th>
40-
</tr>
41-
<tr>
42-
<th>
43-
<strong>Reference</strong>
44-
</th>
45-
<th>
46-
<strong>Product</strong>
47-
</th>
48-
<th class="text-right">
49-
<strong>Quantity</strong>
50-
</th>
51-
</tr>
52-
</thead>
53-
<tbody>
28+
t-if="o.company_id.undelivered_product_slip_report_method == 'completely_undelivered'"
29+
>
5430
<t
55-
t-foreach="undelivered_moves.sorted(key=lambda l: (l.product_id.default_code, l.product_id.name))"
56-
t-as="undelivered_move"
57-
>
58-
<tr
59-
t-att-class="'partially_undelivered_line' if undelivered_move.splitted_stock_move_orig_id else 'completely_undelivered_line'"
60-
>
61-
<td>
62-
<span
63-
t-field="undelivered_move.product_id.default_code"
64-
/>
65-
</td>
66-
<td>
67-
<span t-field="undelivered_move.product_id.name" />
68-
</td>
69-
<td class="text-right">
70-
<span t-field="undelivered_move.product_uom_qty" />
71-
<span
72-
groups="uom.group_uom"
73-
t-field="undelivered_move.product_uom"
74-
/>
75-
</td>
76-
</tr>
77-
</t>
78-
</tbody>
79-
</table>
80-
</t>
81-
</template>
31+
t-set="undelivered_moves"
32+
t-value="all_moves.filtered(lambda l: l.state == 'cancel' and l.product_id.display_undelivered_in_picking and l.product_uom_qty > 0.0)"
33+
/>
34+
</t>
35+
</t>
36+
</xpath>
8237

83-
<template
84-
id="report_delivery_document"
85-
inherit_id="stock.report_delivery_document"
86-
priority="200"
87-
>
8838
<xpath
89-
expr="//table[@t-if=&quot;o.move_line_ids and o.state=='done'&quot;]"
90-
position="after"
39+
expr="//*[@t-if='not (o.backorder_ids and backorders)']"
40+
position="attributes"
9141
>
92-
<t t-call="stock_picking_report_undelivered_product.undeliverd_product" />
42+
<attribute name="t-if">not undelivered_moves</attribute>
43+
</xpath>
44+
45+
<xpath expr="//tr[contains(@t-foreach, 'backorders')]" position="attributes">
46+
<attribute name="t-foreach">undelivered_moves</attribute>
47+
</xpath>
48+
49+
<xpath expr="//td[@class='text-center w-auto']" position="replace">
50+
<td class="text-center w-auto">
51+
<span t-esc="bo_line.product_uom_qty - bo_line.quantity">3.00</span>
52+
<span t-field="bo_line.product_uom" groups="uom.group_uom">units</span>
53+
</td>
9354
</xpath>
9455
</template>
9556
</odoo>

0 commit comments

Comments
 (0)