Skip to content

Commit 9eedb1f

Browse files
committed
[MIG] stock_picking_return_refund_option: Migration to 18.0
1 parent c3869f9 commit 9eedb1f

File tree

8 files changed

+41
-36
lines changed

8 files changed

+41
-36
lines changed

stock_picking_return_refund_option/README.rst

+1
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,7 @@ Contributors
120120

121121
- Sergio Teruel
122122
- César A. Sánchez
123+
- Carlos Roca
123124

124125
Maintainers
125126
-----------

stock_picking_return_refund_option/__manifest__.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@
33
{
44
"name": "Stock Picking Return Refund Option",
55
"summary": "Update the refund options in pickings",
6-
"version": "16.0.1.0.2",
6+
"version": "18.0.1.0.0",
77
"development_status": "Production/Stable",
88
"category": "Sales",
99
"website": "https://github.com/OCA/account-invoicing",
10-
"author": "Tecnativa, " "Odoo Community Association (OCA)",
10+
"author": "Tecnativa, Odoo Community Association (OCA)",
1111
"license": "AGPL-3",
1212
"application": False,
1313
"installable": True,

stock_picking_return_refund_option/models/stock_move.py

+2-4
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@ class StockMove(models.Model):
99
def write(self, vals):
1010
res = super().write(vals)
1111
if "to_refund" in vals:
12-
for move in self:
13-
if move.picking_id:
14-
move.picking_id.set_delivered_qty()
15-
move.picking_id.set_received_qty()
12+
self.picking_id.set_delivered_qty()
13+
self.picking_id.set_received_qty()
1614
return res

stock_picking_return_refund_option/models/stock_picking.py

+3-4
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,9 @@ def _inverse_to_refund_lines(self):
3838
All lines to False.
3939
Each line to original value selected in return wizard by user.
4040
"""
41-
for picking in self:
42-
picking._update_stock_moves()
43-
picking.set_delivered_qty()
44-
picking.set_received_qty()
41+
self._update_stock_moves()
42+
self.set_delivered_qty()
43+
self.set_received_qty()
4544

4645
def _compute_is_return(self):
4746
for picking in self:
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
- [Tecnativa](https://www.tecnativa.com):
22
- Sergio Teruel
33
- César A. Sánchez
4+
- Carlos Roca

stock_picking_return_refund_option/static/description/index.html

+1
Original file line numberDiff line numberDiff line change
@@ -465,6 +465,7 @@ <h2><a class="toc-backref" href="#toc-entry-6">Contributors</a></h2>
465465
<li><a class="reference external" href="https://www.tecnativa.com">Tecnativa</a>:<ul>
466466
<li>Sergio Teruel</li>
467467
<li>César A. Sánchez</li>
468+
<li>Carlos Roca</li>
468469
</ul>
469470
</li>
470471
</ul>

stock_picking_return_refund_option/tests/test_stock_picking_return_refund_options.py

+28-20
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# Copyright 2018 Tecnativa - Sergio Teruel
22
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
3-
from odoo.tests.common import Form, TransactionCase, tagged
3+
from odoo.tests import Form
4+
from odoo.tests.common import TransactionCase, tagged
45

56

67
@tagged("post_install", "-at_install")
@@ -18,23 +19,24 @@ def setUpClass(cls):
1819
tracking_disable=True,
1920
)
2021
)
21-
if not cls.env.company.chart_template_id:
22-
# Load a CoA if there's none in current company
23-
coa = cls.env.ref("l10n_generic_coa.configurable_chart_template", False)
24-
if not coa:
25-
# Load the first available CoA
26-
coa = cls.env["account.chart.template"].search(
27-
[("visible", "=", True)], limit=1
28-
)
29-
coa.try_loading(company=cls.env.company, install_demo=False)
3022
cls.partner = cls.env["res.partner"].create(
3123
{"name": "Test", "customer_rank": 1, "supplier_rank": 1}
3224
)
3325
cls.product = cls.env["product.product"].create(
34-
{"name": "test_product", "type": "product", "invoice_policy": "delivery"}
26+
{
27+
"name": "test_product",
28+
"type": "consu",
29+
"is_storable": True,
30+
"invoice_policy": "delivery",
31+
}
3532
)
3633
cls.product2 = cls.env["product.product"].create(
37-
{"name": "test_product_2", "type": "product", "invoice_policy": "delivery"}
34+
{
35+
"name": "test_product_2",
36+
"type": "consu",
37+
"is_storable": True,
38+
"invoice_policy": "delivery",
39+
}
3840
)
3941
with Form(cls.env["sale.order"]) as order_form:
4042
order_form.partner_id = cls.partner
@@ -50,7 +52,7 @@ def setUpClass(cls):
5052
move_line_vals_list = []
5153
for move in cls.picking.move_ids:
5254
move_line_vals = move._prepare_move_line_vals()
53-
move_line_vals["qty_done"] = 1
55+
move_line_vals["quantity"] = 1
5456
move_line_vals_list.append(move_line_vals)
5557
cls.env["stock.move.line"].create(move_line_vals_list)
5658
cls.picking.button_validate()
@@ -73,8 +75,10 @@ def return_picking_wiz(self, picking):
7375

7476
def test_return_to_refund_values(self):
7577
return_wizard = self.return_picking_wiz(self.picking)
76-
return_pick = self.picking.browse(return_wizard.create_returns()["res_id"])
77-
return_pick.move_line_ids.write({"qty_done": 1.0})
78+
return_pick = self.picking.browse(
79+
return_wizard.action_create_returns()["res_id"]
80+
)
81+
return_pick.move_line_ids.write({"quantity": 1.0})
7882
return_pick.button_validate()
7983
self.assertEqual(return_pick.to_refund_lines, "no_refund")
8084
return_pick.move_ids.write({"to_refund": True})
@@ -85,8 +89,10 @@ def test_return_to_refund_values(self):
8589
def test_return_so_wo_to_refund(self):
8690
# Return some items, after SO was invoiced
8791
return_wizard = self.return_picking_wiz(self.picking)
88-
return_pick = self.picking.browse(return_wizard.create_returns()["res_id"])
89-
return_pick.move_line_ids.write({"qty_done": 1.0})
92+
return_pick = self.picking.browse(
93+
return_wizard.action_create_returns()["res_id"]
94+
)
95+
return_pick.move_line_ids.write({"quantity": 1.0})
9096
return_pick.button_validate()
9197
self.assertEqual(self.order.invoice_status, "invoiced")
9298

@@ -113,15 +119,17 @@ def test_return_po_wo_to_refund(self):
113119
po_order.button_confirm()
114120
picking = po_order.picking_ids[:]
115121
move_line_vals = picking.move_ids._prepare_move_line_vals()
116-
move_line_vals["qty_done"] = 1
122+
move_line_vals["quantity"] = 1
117123
self.env["stock.move.line"].create(move_line_vals)
118124
picking.button_validate()
119125
self.assertEqual(po_order.invoice_status, "to invoice")
120126
# Return the picking without refund
121127
return_wizard = self.return_picking_wiz(picking)
122-
return_pick = self.picking.browse(return_wizard.create_returns()["res_id"])
128+
return_pick = self.picking.browse(
129+
return_wizard.action_create_returns()["res_id"]
130+
)
123131
move_line_vals = return_pick.move_ids._prepare_move_line_vals()
124-
move_line_vals["qty_done"] = 1
132+
move_line_vals["quantity"] = 1
125133
self.env["stock.move.line"].create(move_line_vals)
126134
return_pick.button_validate()
127135
# Now set to be refunded

stock_picking_return_refund_option/views/stock_picking_view.xml

+3-6
Original file line numberDiff line numberDiff line change
@@ -10,19 +10,16 @@
1010
<field name="is_return" invisible="1" />
1111
<field
1212
name="to_refund_lines"
13-
attrs="{'invisible': [('is_return', '=', False)]}"
13+
invisible="not is_return"
1414
string="Refund Options"
1515
/>
1616
</xpath>
1717
<!-- Make visible to_refund field at operations (stock moves) level -->
1818
<xpath
19-
expr="//field[@name='move_ids_without_package']/tree"
19+
expr="//field[@name='move_ids_without_package']/list"
2020
position="inside"
2121
>
22-
<field
23-
name="to_refund"
24-
attrs="{'column_invisible': [('parent.is_return', '=', False)]}"
25-
/>
22+
<field name="to_refund" column_invisible="not parent.is_return" />
2623
</xpath>
2724
</field>
2825
</record>

0 commit comments

Comments
 (0)