Skip to content

Commit c93d504

Browse files
committed
[MIG] account_invoice_refund_line_selection: Migration to 16.0
1 parent 55f2337 commit c93d504

File tree

4 files changed

+20
-38
lines changed

4 files changed

+20
-38
lines changed

account_invoice_refund_line_selection/__manifest__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
{
55
"name": "Account invoice refund line",
6-
"version": "15.0.1.0.0",
6+
"version": "16.0.1.0.0",
77
"category": "Accounting & Finance",
88
"summary": "This module allows the user to refund specific lines in a invoice",
99
"author": "Creu Blanca, Odoo Community Association (OCA)",

account_invoice_refund_line_selection/tests/test_refund_line.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,16 @@ class TestInvoiceRefundLine(AccountTestInvoicingCommon):
1010
@classmethod
1111
def setUpClass(cls, chart_template_ref=None):
1212
super().setUpClass(chart_template_ref=chart_template_ref)
13+
cls.env = cls.env(
14+
context=dict(
15+
cls.env.context,
16+
mail_create_nolog=True,
17+
mail_create_nosubscribe=True,
18+
mail_notrack=True,
19+
no_reset_password=True,
20+
tracking_disable=True,
21+
)
22+
)
1323
cls.in_invoice = cls.init_invoice(
1424
"in_invoice", products=cls.product_a + cls.product_b
1525
)

account_invoice_refund_line_selection/wizards/account_move_reversal.py

Lines changed: 6 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55

66

77
class AccountInvoiceRefund(models.TransientModel):
8-
98
_inherit = "account.move.reversal"
109

1110
refund_method = fields.Selection(
@@ -26,7 +25,7 @@ class AccountInvoiceRefund(models.TransientModel):
2625

2726
@api.model
2827
def default_get(self, fields):
29-
rec = super(AccountInvoiceRefund, self).default_get(fields)
28+
rec = super().default_get(fields)
3029
context = dict(self._context or {})
3130
active_id = context.get("active_id", False)
3231
if active_id:
@@ -45,42 +44,15 @@ def _prepare_default_reversal(self, move):
4544
0,
4645
0,
4746
li.with_context(include_business_fields=True).copy_data(
48-
{"move_id": False, "recompute_tax_line": True}
47+
{"move_id": False}
4948
)[0],
5049
)
5150
for li in self.line_ids
5251
]
53-
move = self.env["account.move"].new(vals)
52+
reversal_inv = self.env["account.move"].new(vals)
5453
lines = []
55-
for line in move._move_autocomplete_invoice_lines_values()["line_ids"]:
56-
if line[0] != 0:
57-
continue
58-
for field_name, field_obj in self.env[
59-
"account.move.line"
60-
]._fields.items():
61-
if (
62-
isinstance(field_obj, fields.Boolean)
63-
and field_obj.store
64-
and field_name not in line[2]
65-
):
66-
line[2][field_name] = False
67-
lines.append(
68-
(
69-
line[0],
70-
line[1],
71-
self.env["account.move.line"]._add_missing_default_values(
72-
line[2]
73-
),
74-
)
75-
)
54+
for line in reversal_inv.line_ids:
55+
dict_line = line._convert_to_write(line._cache)
56+
lines.append((0, 0, dict_line))
7657
res["line_ids"] = lines
7758
return res
78-
79-
def reverse_moves(self):
80-
# We can uncheck the move, as it is checked by default at the end
81-
return super(
82-
AccountInvoiceRefund,
83-
self.with_context(
84-
check_move_validity=False,
85-
),
86-
).reverse_moves()

account_invoice_refund_line_selection/wizards/account_move_reversal_view.xml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
name="line_ids"
1616
context="{'tree_view_ref': 'account.view_move_line_tree_grouped_sales_purchases'}"
1717
>
18-
<tree>
18+
<tree no_open="True">
1919
<field name="sequence" widget="handle" readonly="1" />
2020
<field name="product_id" readonly="1" />
2121
<field name="name" readonly="1" />
@@ -33,11 +33,11 @@
3333
</page>
3434
</notebook>
3535
</xpath>
36-
<xpath expr="//group/div[2]" position="after">
36+
<xpath expr="//group//group/div" position="after">
3737
<div
3838
attrs="{'invisible':[('refund_method','!=','refund_lines')]}"
3939
class="oe_grey"
40-
colspan="4"
40+
colspan="2"
4141
>
4242
Use this option if you want to refund only some specific lines in an invoice.
4343
</div>

0 commit comments

Comments
 (0)