diff --git a/account_invoice_refund_line_selection/__manifest__.py b/account_invoice_refund_line_selection/__manifest__.py index a5679bba19de..22b79e0593d6 100644 --- a/account_invoice_refund_line_selection/__manifest__.py +++ b/account_invoice_refund_line_selection/__manifest__.py @@ -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)", diff --git a/account_invoice_refund_line_selection/tests/test_refund_line.py b/account_invoice_refund_line_selection/tests/test_refund_line.py index a6cfa3e2871b..9ee565d15cf5 100644 --- a/account_invoice_refund_line_selection/tests/test_refund_line.py +++ b/account_invoice_refund_line_selection/tests/test_refund_line.py @@ -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 ) diff --git a/account_invoice_refund_line_selection/wizards/account_move_reversal.py b/account_invoice_refund_line_selection/wizards/account_move_reversal.py index f9c30529da8a..57059155392f 100644 --- a/account_invoice_refund_line_selection/wizards/account_move_reversal.py +++ b/account_invoice_refund_line_selection/wizards/account_move_reversal.py @@ -5,7 +5,6 @@ class AccountInvoiceRefund(models.TransientModel): - _inherit = "account.move.reversal" refund_method = fields.Selection( @@ -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: @@ -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()