[FIX] account: Do not create cash basis entries on non-cash-basis Company
Chances are that Journal Entries are coming from previous migration and they could trigger the creation of CABA Journal Entries even when the company at stake is a non Cash Basis Company. closes odoo/odoo#98954 X-original-commit: fcad4dbdbd65775b75aa94049da06bd0b07295d8 Related: odoo/enterprise#30763 Signed-off-by: Laurent Smet <las@odoo.com>
This commit is contained in:
committed by
Laurent Smet
parent
f02b21771c
commit
67c906f4d2
@@ -2226,7 +2226,7 @@ class AccountMoveLine(models.Model):
|
||||
|
||||
# ==== Create entries for cash basis taxes ====
|
||||
|
||||
is_cash_basis_needed = account.account_type in ('asset_receivable', 'liability_payable')
|
||||
is_cash_basis_needed = account.company_id.tax_exigibility and account.account_type in ('asset_receivable', 'liability_payable')
|
||||
if is_cash_basis_needed and not self._context.get('move_reverse_cancel'):
|
||||
tax_cash_basis_moves = partials._create_tax_cash_basis_moves()
|
||||
results['tax_cash_basis_moves'] = tax_cash_basis_moves
|
||||
|
||||
@@ -182,6 +182,8 @@ class TestAccountMoveDateAlgorithm(AccountTestInvoicingCommon):
|
||||
}])
|
||||
|
||||
def test_caba_with_lock_date(self):
|
||||
self.env.company.tax_exigibility = True
|
||||
|
||||
tax_waiting_account = self.env['account.account'].create({
|
||||
'name': 'TAX_WAIT',
|
||||
'code': 'TWAIT',
|
||||
|
||||
@@ -649,6 +649,7 @@ class TestAccountMove(AccountTestInvoicingCommon):
|
||||
'company_id': self.company_data['company'].id,
|
||||
})
|
||||
self.env.company.account_cash_basis_base_account_id = tax_base_amount_account
|
||||
self.env.company.tax_exigibility = True
|
||||
tax_tags = defaultdict(dict)
|
||||
for line_type, repartition_type in [(l, r) for l in ('invoice', 'refund') for r in ('base', 'tax')]:
|
||||
tax_tags[line_type][repartition_type] = self.env['account.account.tag'].create({
|
||||
|
||||
@@ -1853,6 +1853,7 @@ class TestAccountMoveInInvoiceOnchanges(AccountTestInvoicingCommon):
|
||||
'company_id': self.company_data['company'].id,
|
||||
})
|
||||
self.env.company.account_cash_basis_base_account_id = tax_base_amount_account
|
||||
self.env.company.tax_exigibility = True
|
||||
tax_tags = defaultdict(dict)
|
||||
for line_type, repartition_type in [(l, r) for l in ('invoice', 'refund') for r in ('base', 'tax')]:
|
||||
tax_tags[line_type][repartition_type] = self.env['account.account.tag'].create({
|
||||
|
||||
@@ -1026,6 +1026,7 @@ class TestAccountMoveInRefundOnchanges(AccountTestInvoicingCommon):
|
||||
'company_id': self.company_data['company'].id,
|
||||
})
|
||||
self.env.company.account_cash_basis_base_account_id = tax_base_amount_account
|
||||
self.env.company.tax_exigibility = True
|
||||
tax_tags = defaultdict(dict)
|
||||
for line_type, repartition_type in [(l, r) for l in ('invoice', 'refund') for r in ('base', 'tax')]:
|
||||
tax_tags[line_type][repartition_type] = self.env['account.account.tag'].create({
|
||||
|
||||
@@ -3149,6 +3149,7 @@ class TestAccountMoveOutInvoiceOnchanges(AccountTestInvoicingCommon):
|
||||
'company_id': self.company_data['company'].id,
|
||||
})
|
||||
self.env.company.account_cash_basis_base_account_id = tax_base_amount_account
|
||||
self.env.company.tax_exigibility = True
|
||||
tax_tags = defaultdict(dict)
|
||||
for line_type, repartition_type in [(l, r) for l in ('invoice', 'refund') for r in ('base', 'tax')]:
|
||||
tax_tags[line_type][repartition_type] = self.env['account.account.tag'].create({
|
||||
|
||||
@@ -982,6 +982,7 @@ class TestAccountMoveOutRefundOnchanges(AccountTestInvoicingCommon):
|
||||
'company_id': self.company_data['company'].id,
|
||||
})
|
||||
self.env.company.account_cash_basis_base_account_id = tax_base_amount_account
|
||||
self.env.company.tax_exigibility = True
|
||||
tax_tags = defaultdict(dict)
|
||||
for line_type, repartition_type in [(l, r) for l in ('invoice', 'refund') for r in ('base', 'tax')]:
|
||||
tax_tags[line_type][repartition_type] = self.env['account.account.tag'].create({
|
||||
|
||||
@@ -2353,6 +2353,7 @@ class TestAccountMoveReconcile(AccountTestInvoicingCommon):
|
||||
- Check there is no rounding issue when making the percentage.
|
||||
- Check there is no lost cents when the journal entry is fully reconciled.
|
||||
'''
|
||||
self.env.company.tax_exigibility = True
|
||||
self.cash_basis_tax_tiny_amount.amount = 0.01
|
||||
cash_basis_move = self.env['account.move'].with_context(skip_invoice_sync=True).create({
|
||||
'move_type': 'entry',
|
||||
@@ -2559,6 +2560,7 @@ class TestAccountMoveReconcile(AccountTestInvoicingCommon):
|
||||
def test_reconcile_cash_basis_workflow_multi_currency(self):
|
||||
''' Same as before with a foreign currency. '''
|
||||
|
||||
self.env.company.tax_exigibility = True
|
||||
currency_id = self.currency_data['currency'].id
|
||||
taxes = self.cash_basis_tax_a_third_amount + self.cash_basis_tax_tiny_amount
|
||||
|
||||
@@ -2784,6 +2786,7 @@ class TestAccountMoveReconcile(AccountTestInvoicingCommon):
|
||||
''' Test the generation of the exchange difference for a tax cash basis journal entry when the transfer
|
||||
account is not reconcilable.
|
||||
'''
|
||||
self.env.company.tax_exigibility = True
|
||||
currency_id = self.currency_data['currency'].id
|
||||
|
||||
# Rate 1/3 in 2016.
|
||||
@@ -2914,6 +2917,7 @@ class TestAccountMoveReconcile(AccountTestInvoicingCommon):
|
||||
''' Test the generation of the exchange difference for a tax cash basis journal entry when the transfer
|
||||
account is not a reconcile one.
|
||||
'''
|
||||
self.env.company.tax_exigibility = True
|
||||
currency_id = self.setup_multi_currency_data(default_values={
|
||||
'name': 'bitcoin',
|
||||
'symbol': 'bc',
|
||||
@@ -3002,6 +3006,7 @@ class TestAccountMoveReconcile(AccountTestInvoicingCommon):
|
||||
''' Test the generation of the exchange difference for a tax cash basis journal entry when the transfer
|
||||
account is not a reconcile one.
|
||||
'''
|
||||
self.env.company.tax_exigibility = True
|
||||
currency_id = self.setup_multi_currency_data(default_values={
|
||||
'name': 'bitcoin',
|
||||
'symbol': 'bc',
|
||||
@@ -3091,6 +3096,7 @@ class TestAccountMoveReconcile(AccountTestInvoicingCommon):
|
||||
''' Test the generation of the exchange difference for a tax cash basis journal entry when the tax
|
||||
account is a reconcile one.
|
||||
'''
|
||||
self.env.company.tax_exigibility = True
|
||||
currency_id = self.currency_data['currency'].id
|
||||
cash_basis_transition_account = self.env['account.account'].create({
|
||||
'code': '209.01.01',
|
||||
@@ -3204,6 +3210,7 @@ class TestAccountMoveReconcile(AccountTestInvoicingCommon):
|
||||
|
||||
def test_reconcile_cash_basis_revert(self):
|
||||
''' Ensure the cash basis journal entry can be reverted. '''
|
||||
self.env.company.tax_exigibility = True
|
||||
self.cash_basis_transfer_account.reconcile = True
|
||||
self.cash_basis_tax_a_third_amount.cash_basis_transition_account_id = self.tax_account_1
|
||||
|
||||
@@ -3285,6 +3292,7 @@ class TestAccountMoveReconcile(AccountTestInvoicingCommon):
|
||||
self.assertFullReconcile(reversed_taxes_full_reconcile, reversed_taxes_lines)
|
||||
|
||||
def test_reconcile_cash_basis_tax_grid_refund(self):
|
||||
self.env.company.tax_exigibility = True
|
||||
invoice_move = self.env['account.move'].create({
|
||||
'move_type': 'entry',
|
||||
'date': '2016-01-01',
|
||||
@@ -3414,6 +3422,7 @@ class TestAccountMoveReconcile(AccountTestInvoicingCommon):
|
||||
|
||||
def test_reconcile_cash_basis_tax_grid_multi_taxes(self):
|
||||
''' Test the tax grid when reconciling an invoice with multiple taxes/tax repartition. '''
|
||||
self.env.company.tax_exigibility = True
|
||||
base_taxes = self.cash_basis_tax_a_third_amount + self.cash_basis_tax_tiny_amount
|
||||
base_tags = self.tax_tags[0] + self.tax_tags[4]
|
||||
|
||||
@@ -3491,6 +3500,7 @@ class TestAccountMoveReconcile(AccountTestInvoicingCommon):
|
||||
|
||||
# Make the tax account reconcilable
|
||||
self.tax_account_1.reconcile = True
|
||||
self.env.company.tax_exigibility = True
|
||||
|
||||
# Create a tax using the same accounts as the CABA one
|
||||
non_caba_tax = self.env['account.tax'].create({
|
||||
@@ -3567,6 +3577,7 @@ class TestAccountMoveReconcile(AccountTestInvoicingCommon):
|
||||
self.env.user.groups_id += self.env.ref('analytic.group_analytic_accounting')
|
||||
# Make the tax account reconcilable
|
||||
self.tax_account_1.reconcile = True
|
||||
self.env.company.tax_exigibility = True
|
||||
|
||||
# Create an invoice with a CABA tax using 'Include in analytic cost'
|
||||
move_form = Form(self.env['account.move'].with_context(default_move_type='in_invoice', account_predictive_bills_disable_prediction=True))
|
||||
@@ -3615,6 +3626,7 @@ class TestAccountMoveReconcile(AccountTestInvoicingCommon):
|
||||
def test_caba_double_tax_negative_line(self):
|
||||
""" Tests making a cash basis invoice with 2 lines using the same tax: a positive and a negative one.
|
||||
"""
|
||||
self.env.company.tax_exigibility = True
|
||||
invoice = self.init_invoice('in_invoice', amounts=[300, -60], post=True, taxes=self.cash_basis_tax_a_third_amount)
|
||||
|
||||
pmt_wizard = self.env['account.payment.register'].with_context(active_model='account.move', active_ids=invoice.ids).create({
|
||||
@@ -3647,6 +3659,7 @@ class TestAccountMoveReconcile(AccountTestInvoicingCommon):
|
||||
|
||||
# Make the tax account reconcilable
|
||||
self.tax_account_1.reconcile = True
|
||||
self.env.company.tax_exigibility = True
|
||||
|
||||
# Create an invoice with a CABA tax using the same tax account and pay half of it
|
||||
caba_inv = self.init_invoice('in_invoice', amounts=[900], post=True, taxes=self.cash_basis_tax_a_third_amount)
|
||||
@@ -3715,6 +3728,8 @@ class TestAccountMoveReconcile(AccountTestInvoicingCommon):
|
||||
bill.button_draft()
|
||||
|
||||
def test_caba_foreign_vat(self):
|
||||
self.env.company.tax_exigibility = True
|
||||
|
||||
test_country = self.env['res.country'].create({
|
||||
'name': "Bretonnia",
|
||||
'code': 'wh',
|
||||
@@ -3772,6 +3787,8 @@ class TestAccountMoveReconcile(AccountTestInvoicingCommon):
|
||||
""" Test the CABA entries generated from an invoice with
|
||||
a tax group
|
||||
"""
|
||||
self.env.company.tax_exigibility = True
|
||||
|
||||
# Make the tax account reconcilable
|
||||
self.tax_account_1.reconcile = True
|
||||
|
||||
|
||||
@@ -213,6 +213,7 @@ class TestValuationReconciliation(ValuationReconciliationTestCommon):
|
||||
def test_reconcile_cash_basis_bill(self):
|
||||
''' Test the generation of the CABA move after bill payment
|
||||
'''
|
||||
self.env.company.tax_exigibility = True
|
||||
cash_basis_base_account = self.env['account.account'].create({
|
||||
'code': 'cash.basis.base.account',
|
||||
'name': 'cash_basis_base_account',
|
||||
|
||||
Reference in New Issue
Block a user