Skip to content

Commit

Permalink
[MIG] account_invoice_refund_line_selection: Migration to 16.0
Browse files Browse the repository at this point in the history
  • Loading branch information
RodrigoBM committed May 29, 2023
1 parent 9540d14 commit 4c62145
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 38 deletions.
2 changes: 1 addition & 1 deletion account_invoice_refund_line_selection/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

{
"name": "Account invoice refund line",
"version": "15.0.1.0.0",
"version": "16.0.1.0.0",
"category": "Accounting & Finance",
"summary": "This module allows the user to refund specific lines in a invoice",
"author": "Creu Blanca, Odoo Community Association (OCA)",
Expand Down
10 changes: 10 additions & 0 deletions account_invoice_refund_line_selection/tests/test_refund_line.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,16 @@ class TestInvoiceRefundLine(AccountTestInvoicingCommon):
@classmethod
def setUpClass(cls, chart_template_ref=None):
super().setUpClass(chart_template_ref=chart_template_ref)
cls.env = cls.env(
context=dict(
cls.env.context,
mail_create_nolog=True,
mail_create_nosubscribe=True,
mail_notrack=True,
no_reset_password=True,
tracking_disable=True,
)
)
cls.in_invoice = cls.init_invoice(
"in_invoice", products=cls.product_a + cls.product_b
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@


class AccountInvoiceRefund(models.TransientModel):

_inherit = "account.move.reversal"

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

@api.model
def default_get(self, fields):
rec = super(AccountInvoiceRefund, self).default_get(fields)
rec = super().default_get(fields)
context = dict(self._context or {})
active_id = context.get("active_id", False)
if active_id:
Expand All @@ -45,42 +44,15 @@ def _prepare_default_reversal(self, move):
0,
0,
li.with_context(include_business_fields=True).copy_data(
{"move_id": False, "recompute_tax_line": True}
{"move_id": False}
)[0],
)
for li in self.line_ids
]
move = self.env["account.move"].new(vals)
reversal_inv = self.env["account.move"].new(vals)
lines = []
for line in move._move_autocomplete_invoice_lines_values()["line_ids"]:
if line[0] != 0:
continue
for field_name, field_obj in self.env[
"account.move.line"
]._fields.items():
if (
isinstance(field_obj, fields.Boolean)
and field_obj.store
and field_name not in line[2]
):
line[2][field_name] = False
lines.append(
(
line[0],
line[1],
self.env["account.move.line"]._add_missing_default_values(
line[2]
),
)
)
for line in reversal_inv.line_ids:
dict_line = line._convert_to_write(line._cache)
lines.append((0, 0, dict_line))
res["line_ids"] = lines
return res

def reverse_moves(self):
# We can uncheck the move, as it is checked by default at the end
return super(
AccountInvoiceRefund,
self.with_context(
check_move_validity=False,
),
).reverse_moves()
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
name="line_ids"
context="{'tree_view_ref': 'account.view_move_line_tree_grouped_sales_purchases'}"
>
<tree>
<tree no_open="True">
<field name="sequence" widget="handle" readonly="1" />
<field name="product_id" readonly="1" />
<field name="name" readonly="1" />
Expand All @@ -33,11 +33,11 @@
</page>
</notebook>
</xpath>
<xpath expr="//group/div[2]" position="after">
<xpath expr="//group//group/div" position="after">
<div
attrs="{'invisible':[('refund_method','!=','refund_lines')]}"
class="oe_grey"
colspan="4"
colspan="2"
>
Use this option if you want to refund only some specific lines in an invoice.
</div>
Expand Down

0 comments on commit 4c62145

Please sign in to comment.