Skip to content
Permalink
Browse files

[REF] account: Add new test to validate the correct revert of an invo…

…ice account.move when the tax cash basis account has set reconcile True.

[REF] account: Not create cash basis move when reversing an invoice
  • Loading branch information...
keylor2906 committed Feb 27, 2019
1 parent 9d3fed6 commit 35f2e508024e29a7f61efd5069991381950be542
Showing with 42 additions and 1 deletion.
  1. +1 −1 addons/account/models/account_move.py
  2. +41 −0 addons/account/tests/test_reconciliation.py
@@ -823,7 +823,7 @@ def _reconcile_lines(self, debit_moves, credit_moves, field):
"""
(debit_moves + credit_moves).read([field])
to_create = []
cash_basis = debit_moves and debit_moves[0].account_id.internal_type in ('receivable', 'payable') or False
cash_basis = debit_moves and debit_moves[0].account_id.internal_type in ('receivable', 'payable') and not debit_moves[0].invoice_id or False
cash_basis_percentage_before_rec = {}
dc_vals ={}
while (debit_moves and credit_moves):
@@ -776,6 +776,47 @@ def test_unreconcile_exchange(self):
credit_aml.with_context(invoice_id=inv.id).remove_move_reconcile()
self.assertAlmostEquals(inv.residual, 111)

def test_revert_in_invoice_move(self):
company = self.env.ref('base.main_company')
company.tax_cash_basis_journal_id = self.cash_basis_journal
company.tax_exibility = True
invoice = self.create_invoice(
type='in_invoice', invoice_amount=50,
currency_id=self.currency_usd_id)
invoice.journal_id.update_posted = True
invoice.action_cancel()
invoice.state = 'draft'
invoice.invoice_line_ids.write({
'invoice_line_tax_ids': [(6, 0, [self.tax_cash_basis.id])]})
invoice.compute_taxes()
invoice.action_invoice_open()
reversed_move_list = invoice.move_id.reverse_moves()
self.assertEqual(len(reversed_move_list), 1)

def test_revert_out_invoice_move(self):
company = self.env.ref('base.main_company')
company.tax_cash_basis_journal_id = self.cash_basis_journal
company.tax_exibility = True
tax_cash_basis_sale = self.tax_cash_basis.copy({
'type_tax_use': 'sale',
'account_id': self.tax_final_account.id,
'cash_basis_account_id': self.tax_waiting_account.id,
})
self.tax_final_account.reconcile = True
invoice = self.create_invoice(
type='out_invoice', invoice_amount=50,
currency_id=self.currency_usd_id)
invoice.journal_id.update_posted = True
invoice.action_cancel()
invoice.state = 'draft'
invoice.invoice_line_ids.write({
'invoice_line_tax_ids': [(6, 0, [tax_cash_basis_sale.id])]})
invoice.compute_taxes()
invoice.action_invoice_open()
reversed_move_list = invoice.move_id.reverse_moves()
self.assertEqual(len(reversed_move_list), 1)


def test_revert_payment_and_reconcile(self):
payment = self.env['account.payment'].create({
'payment_method_id': self.inbound_payment_method.id,

0 comments on commit 35f2e50

Please sign in to comment.
You can’t perform that action at this time.