[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
This commit is contained in:
Sohail Jaidi (soja)
2023-05-17 13:37:54 +02:00
committed by Sohail JAIDI (soja)
parent 7e65ab7199
commit dbd9b9dcfe
6 changed files with 101 additions and 100 deletions
@@ -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):
@@ -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):
@@ -64,8 +64,8 @@
<InvoiceClass>OO</InvoiceClass>
<Corrective>
<InvoiceNumber>INV/2023/00001</InvoiceNumber>
<ReasonCode>01</ReasonCode>
<ReasonDescription>Invoice number</ReasonDescription>
<ReasonCode>10</ReasonCode>
<ReasonDescription>Transaction Details</ReasonDescription>
<TaxPeriod>
<StartDate>2023-01-01</StartDate>
<EndDate>2023-01-31</EndDate>
@@ -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)
@@ -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):
@@ -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