Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[REF] account: Add test for issue#30972 #31480

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion addons/account/models/account_move.py
Expand Up @@ -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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why only the debit_move and not the credit_move?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

does it work for both the in_invoice and the out_invoice?

it is quite weird for me.

Regards

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Being honest, I don't really know why the debit_moves and not the credit_moves, I only did the change based on the previous criteria for creating a cash basis move (debit_moves) and works for both cases, in and out invoices.

cash_basis_percentage_before_rec = {}
dc_vals ={}
while (debit_moves and credit_moves):
Expand Down
41 changes: 41 additions & 0 deletions addons/account/tests/test_reconciliation.py
Expand Up @@ -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({
keylor2906 marked this conversation as resolved.
Show resolved Hide resolved
'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,
Expand Down