From dbd9b9dcfe135acf72ffbb2e42cd5f12619f8bc0 Mon Sep 17 00:00:00 2001 From: "Sohail Jaidi (soja)" Date: Mon, 15 May 2023 13:08:59 +0000 Subject: [PATCH] [REF] account,*: going from cancel to modify in tests After the modification of the credit note wizard the option 'cancel' is not available anymore. Since there was no test for 'modify' and the 'refund' option was already tested, the tests are modified so that it now tests 'modify' option task id: 3244377 Part-of: odoo/odoo#117961 --- .../tests/test_account_move_in_invoice.py | 88 +++++++++---------- .../tests/test_account_move_out_invoice.py | 88 +++++++++---------- .../tests/data/expected_refund_document.xml | 4 +- .../tests/test_edi_xml.py | 5 +- ...st_anglo_saxon_valuation_reconciliation.py | 7 +- ...st_anglo_saxon_valuation_reconciliation.py | 9 +- 6 files changed, 101 insertions(+), 100 deletions(-) diff --git a/addons/account/tests/test_account_move_in_invoice.py b/addons/account/tests/test_account_move_in_invoice.py index d129c300381..d98fae1ef34 100644 --- a/addons/account/tests/test_account_move_in_invoice.py +++ b/addons/account/tests/test_account_move_in_invoice.py @@ -1168,53 +1168,53 @@ class TestAccountMoveInInvoiceOnchanges(AccountTestInvoicingCommon): move_reversal = self.env['account.move.reversal'].with_context(active_model="account.move", active_ids=self.invoice.ids).create({ 'date': fields.Date.from_string('2019-02-01'), 'reason': 'no reason again', - 'refund_method': 'cancel', + 'refund_method': 'modify', 'journal_id': self.invoice.journal_id.id, }) reversal = move_reversal.reverse_moves() - reverse_move = self.env['account.move'].browse(reversal['res_id']) + new_move = self.env['account.move'].browse(reversal['res_id']) self.assertEqual(self.invoice.payment_state, 'reversed', "After cancelling it with a reverse invoice, an invoice should be in 'reversed' state.") - self.assertInvoiceValues(reverse_move, [ + self.assertInvoiceValues(new_move, [ { **self.product_line_vals_1, - 'amount_currency': -800.0, - 'debit': 0.0, - 'credit': 800.0, + 'amount_currency': 800.0, + 'debit': 800.0, + 'credit': 0.0, }, { **self.product_line_vals_2, - 'amount_currency': -160.0, - 'debit': 0.0, - 'credit': 160.0, + 'amount_currency': 160.0, + 'debit': 160.0, + 'credit': 0.0, }, { **self.tax_line_vals_1, - 'amount_currency': -144.0, - 'debit': 0.0, - 'credit': 144.0, + 'amount_currency': 144.0, + 'debit': 144.0, + 'credit': 0.0, }, { **self.tax_line_vals_2, - 'amount_currency': -24.0, - 'debit': 0.0, - 'credit': 24.0, + 'amount_currency': 24.0, + 'debit': 24.0, + 'credit': 0.0, }, { **self.term_line_vals_1, 'name': '', - 'amount_currency': 1128.0, - 'debit': 1128.0, - 'credit': 0.0, + 'amount_currency': -1128.0, + 'debit': 0.0, + 'credit': 1128.0, 'date_maturity': move_reversal.date, }, ], { **self.move_vals, - 'invoice_payment_term_id': None, + 'invoice_payment_term_id': self.pay_terms_a.id, 'date': move_reversal.date, - 'state': 'posted', - 'ref': 'Reversal of: %s, %s' % (self.invoice.name, move_reversal.reason), - 'payment_state': 'paid', + 'state': 'draft', + 'ref': False, + 'payment_state': 'not_paid', }) def test_in_invoice_create_refund_multi_currency(self): @@ -1289,59 +1289,59 @@ class TestAccountMoveInInvoiceOnchanges(AccountTestInvoicingCommon): move_reversal = self.env['account.move.reversal'].with_context(active_model="account.move", active_ids=self.invoice.ids).create({ 'date': fields.Date.from_string('2017-01-01'), 'reason': 'no reason again', - 'refund_method': 'cancel', + 'refund_method': 'modify', 'journal_id': self.invoice.journal_id.id, }) reversal = move_reversal.reverse_moves() - reverse_move = self.env['account.move'].browse(reversal['res_id']) + new_move = self.env['account.move'].browse(reversal['res_id']) self.assertEqual(self.invoice.payment_state, 'reversed', "After cancelling it with a reverse invoice, an invoice should be in 'reversed' state.") - self.assertInvoiceValues(reverse_move, [ + self.assertInvoiceValues(new_move, [ { **self.product_line_vals_1, - 'amount_currency': -800.0, + 'amount_currency': 800.0, 'currency_id': self.currency_data['currency'].id, - 'debit': 0.0, - 'credit': 400.0, + 'debit': 400.0, + 'credit': 0.0, }, { **self.product_line_vals_2, - 'amount_currency': -160.0, + 'amount_currency': 160.0, 'currency_id': self.currency_data['currency'].id, - 'debit': 0.0, - 'credit': 80.0, + 'debit': 80.0, + 'credit': 0.0, }, { **self.tax_line_vals_1, - 'amount_currency': -144.0, + 'amount_currency': 144.0, 'currency_id': self.currency_data['currency'].id, - 'debit': 0.0, - 'credit': 72.0, + 'debit': 72.0, + 'credit': 0.0, }, { **self.tax_line_vals_2, - 'amount_currency': -24.0, + 'amount_currency': 24.0, 'currency_id': self.currency_data['currency'].id, - 'debit': 0.0, - 'credit': 12.0, + 'debit': 12.0, + 'credit': 0.0, }, { **self.term_line_vals_1, 'name': '', - 'amount_currency': 1128.0, + 'amount_currency': -1128.0, 'currency_id': self.currency_data['currency'].id, - 'debit': 564.0, - 'credit': 0.0, + 'debit': 0.0, + 'credit': 564.0, 'date_maturity': move_reversal.date, }, ], { **self.move_vals, - 'invoice_payment_term_id': None, + 'invoice_payment_term_id': self.pay_terms_a.id, 'currency_id': self.currency_data['currency'].id, 'date': move_reversal.date, - 'state': 'posted', - 'ref': 'Reversal of: %s, %s' % (self.invoice.name, move_reversal.reason), - 'payment_state': 'paid', + 'state': 'draft', + 'ref': False, + 'payment_state': 'not_paid', }) def test_in_invoice_create_1(self): diff --git a/addons/account/tests/test_account_move_out_invoice.py b/addons/account/tests/test_account_move_out_invoice.py index b209b49c8a7..0f0068f8ae9 100644 --- a/addons/account/tests/test_account_move_out_invoice.py +++ b/addons/account/tests/test_account_move_out_invoice.py @@ -1785,53 +1785,53 @@ class TestAccountMoveOutInvoiceOnchanges(AccountTestInvoicingCommon): move_reversal = self.env['account.move.reversal'].with_context(active_model="account.move", active_ids=self.invoice.ids).create({ 'date': fields.Date.from_string('2019-02-01'), 'reason': 'no reason', - 'refund_method': 'cancel', + 'refund_method': 'modify', 'journal_id': self.invoice.journal_id.id, }) reversal = move_reversal.reverse_moves() - reverse_move = self.env['account.move'].browse(reversal['res_id']) + new_move = self.env['account.move'].browse(reversal['res_id']) self.assertEqual(self.invoice.payment_state, 'reversed', "After cancelling it with a reverse invoice, an invoice should be in 'reversed' state.") - self.assertInvoiceValues(reverse_move, [ + self.assertInvoiceValues(new_move, [ { **self.product_line_vals_1, - 'amount_currency': 1000.0, - 'debit': 1000.0, - 'credit': 0.0, + 'amount_currency': -1000.0, + 'debit': 0.0, + 'credit': 1000.0, }, { **self.product_line_vals_2, - 'amount_currency': 200.0, - 'debit': 200.0, - 'credit': 0.0, + 'amount_currency': -200.0, + 'debit': 0.0, + 'credit': 200.0, }, { **self.tax_line_vals_1, - 'amount_currency': 180.0, - 'debit': 180.0, - 'credit': 0.0, + 'amount_currency': -180.0, + 'debit': 0.0, + 'credit': 180.0, }, { **self.tax_line_vals_2, - 'amount_currency': 30.0, - 'debit': 30.0, - 'credit': 0.0, + 'amount_currency': -30.0, + 'debit': 0.0, + 'credit': 30.0, }, { **self.term_line_vals_1, 'name': '', - 'amount_currency': -1410.0, - 'debit': 0.0, - 'credit': 1410.0, + 'amount_currency': 1410.0, + 'debit': 1410.0, + 'credit': 0.0, 'date_maturity': move_reversal.date, }, ], { **self.move_vals, - 'invoice_payment_term_id': None, + 'invoice_payment_term_id': self.pay_terms_a.id, 'date': move_reversal.date, - 'state': 'posted', - 'ref': 'Reversal of: %s, %s' % (self.invoice.name, move_reversal.reason), - 'payment_state': 'paid', + 'state': 'draft', + 'ref': False, + 'payment_state': 'not_paid', }) def test_out_invoice_create_refund_multi_currency(self): @@ -1906,59 +1906,59 @@ class TestAccountMoveOutInvoiceOnchanges(AccountTestInvoicingCommon): move_reversal = self.env['account.move.reversal'].with_context(active_model="account.move", active_ids=self.invoice.ids).create({ 'date': fields.Date.from_string('2017-01-01'), 'reason': 'no reason', - 'refund_method': 'cancel', + 'refund_method': 'modify', 'journal_id': self.invoice.journal_id.id, }) reversal = move_reversal.reverse_moves() - reverse_move = self.env['account.move'].browse(reversal['res_id']) + new_move = self.env['account.move'].browse(reversal['res_id']) self.assertEqual(self.invoice.payment_state, 'reversed', "After cancelling it with a reverse invoice, an invoice should be in 'reversed' state.") - self.assertInvoiceValues(reverse_move, [ + self.assertInvoiceValues(new_move, [ { **self.product_line_vals_1, - 'amount_currency': 1000.0, + 'amount_currency': -1000.0, 'currency_id': self.currency_data['currency'].id, - 'debit': 500.0, - 'credit': 0.0, + 'debit': 0.0, + 'credit': 500.0, }, { **self.product_line_vals_2, - 'amount_currency': 200.0, + 'amount_currency': -200.0, 'currency_id': self.currency_data['currency'].id, - 'debit': 100.0, - 'credit': 0.0, + 'debit': 0.0, + 'credit': 100.0, }, { **self.tax_line_vals_1, - 'amount_currency': 180.0, + 'amount_currency': -180.0, 'currency_id': self.currency_data['currency'].id, - 'debit': 90.0, - 'credit': 0.0, + 'debit': 0.0, + 'credit': 90.0, }, { **self.tax_line_vals_2, - 'amount_currency': 30.0, + 'amount_currency': -30.0, 'currency_id': self.currency_data['currency'].id, - 'debit': 15.0, - 'credit': 0.0, + 'debit': 0.0, + 'credit': 15.0, }, { **self.term_line_vals_1, 'name': '', - 'amount_currency': -1410.0, + 'amount_currency': 1410.0, 'currency_id': self.currency_data['currency'].id, - 'debit': 0.0, - 'credit': 705.0, + 'debit': 705.0, + 'credit': 0.0, 'date_maturity': move_reversal.date, }, ], { **self.move_vals, - 'invoice_payment_term_id': None, + 'invoice_payment_term_id': self.pay_terms_a.id, 'currency_id': self.currency_data['currency'].id, 'date': move_reversal.date, - 'state': 'posted', - 'ref': 'Reversal of: %s, %s' % (self.invoice.name, move_reversal.reason), - 'payment_state': 'paid', + 'state': 'draft', + 'ref': False, + 'payment_state': 'not_paid', }) def test_out_invoice_create_refund_auto_post(self): diff --git a/addons/l10n_es_edi_facturae/tests/data/expected_refund_document.xml b/addons/l10n_es_edi_facturae/tests/data/expected_refund_document.xml index 0ce979bf3c3..d21a859ca21 100644 --- a/addons/l10n_es_edi_facturae/tests/data/expected_refund_document.xml +++ b/addons/l10n_es_edi_facturae/tests/data/expected_refund_document.xml @@ -64,8 +64,8 @@ OO INV/2023/00001 - 01 - Invoice number + 10 + Transaction Details 2023-01-01 2023-01-31 diff --git a/addons/l10n_es_edi_facturae/tests/test_edi_xml.py b/addons/l10n_es_edi_facturae/tests/test_edi_xml.py index 6b5e856a5b7..c6c07b85b1b 100644 --- a/addons/l10n_es_edi_facturae/tests/test_edi_xml.py +++ b/addons/l10n_es_edi_facturae/tests/test_edi_xml.py @@ -205,15 +205,14 @@ class TestEdiFacturaeXmls(AccountEdiTestCommon): invoice.action_post() reversal_wizard = self.env['account.move.reversal'].create({ 'move_ids': invoice.ids, - 'date_mode': 'custom', 'journal_id': invoice.journal_id.id, 'date': self.frozen_today, - 'refund_method': 'cancel', + 'refund_method': 'modify', 'company_id': self.company_data['company'].id, 'l10n_es_edi_facturae_reason_code': '01' }) reversal_wizard.reverse_moves() - refund = reversal_wizard.new_move_ids + refund = invoice.reversal_move_id generated_file = refund._l10n_es_edi_facturae_render_facturae() self.assertTrue(generated_file) diff --git a/addons/purchase_stock/tests/test_anglo_saxon_valuation_reconciliation.py b/addons/purchase_stock/tests/test_anglo_saxon_valuation_reconciliation.py index d2d0a7f89b1..69e51c811aa 100644 --- a/addons/purchase_stock/tests/test_anglo_saxon_valuation_reconciliation.py +++ b/addons/purchase_stock/tests/test_anglo_saxon_valuation_reconciliation.py @@ -106,15 +106,16 @@ class TestValuationReconciliation(ValuationReconciliationTestCommon): # Refund the invoice refund_invoice_wiz = self.env['account.move.reversal'].with_context(active_model="account.move", active_ids=[invoice.id]).create({ 'reason': 'test_invoice_shipment_refund', - 'refund_method': 'cancel', + 'refund_method': 'modify', 'date': '2018-03-15', 'journal_id': invoice.journal_id.id, }) - refund_invoice = self.env['account.move'].browse(refund_invoice_wiz.reverse_moves()['res_id']) - + new_invoice = self.env['account.move'].browse(refund_invoice_wiz.reverse_moves()['res_id']) + refund_invoice = invoice.reversal_move_id # Check the result self.assertEqual(invoice.payment_state, 'reversed', "Invoice should be in 'reversed' state") self.assertEqual(refund_invoice.payment_state, 'paid', "Refund should be in 'paid' state") + self.assertEqual(new_invoice.state, 'draft', "New invoice should be in 'draft' state") self.check_reconciliation(refund_invoice, return_pick) def test_multiple_shipments_invoices(self): diff --git a/addons/sale_stock/tests/test_anglo_saxon_valuation_reconciliation.py b/addons/sale_stock/tests/test_anglo_saxon_valuation_reconciliation.py index 98238885c96..763253041a8 100644 --- a/addons/sale_stock/tests/test_anglo_saxon_valuation_reconciliation.py +++ b/addons/sale_stock/tests/test_anglo_saxon_valuation_reconciliation.py @@ -116,13 +116,14 @@ class TestValuationReconciliation(TestValuationReconciliationCommon): return_pick._action_done() refund_invoice_wiz = self.env['account.move.reversal'].with_context(active_model='account.move', active_ids=[invoice.id]).create({ 'reason': 'test_invoice_shipment_refund', - 'refund_method': 'cancel', + 'refund_method': 'modify', 'journal_id': invoice.journal_id.id, }) - refund_invoice = self.env['account.move'].browse(refund_invoice_wiz.reverse_moves()['res_id']) + new_invoice = self.env['account.move'].browse(refund_invoice_wiz.reverse_moves()['res_id']) self.assertEqual(invoice.payment_state, 'reversed', "Invoice should be in 'reversed' state.") - self.assertEqual(refund_invoice.payment_state, 'paid', "Refund should be in 'paid' state.") - self.check_reconciliation(refund_invoice, return_pick, operation='sale') + self.assertEqual(invoice.reversal_move_id.payment_state, 'paid', "Refund should be in 'paid' state.") + self.assertEqual(new_invoice.state, 'draft', "New invoice should be in 'draft' state.") + self.check_reconciliation(invoice.reversal_move_id, return_pick, operation='sale') def test_multiple_shipments_invoices(self): """ Tests the case into which we deliver part of the goods first, then 2 invoices at different rates, and finally the remaining quantities