Before, account_fiscal_country_id was only use for tax operations; and country_id was used for all the other accounting stuff. Now, with the new ability to use foreign tax reports (with foreign VAT fiscal positions), we can generalize the fiscal country, sot that it is the one that needs to be used for the whole accounting. Since foreign tax reports were not supported before, account_fiscal_country_id is already set on existing database as the country for the "main" accounting, so the impact of this change is small. closes odoo/odoo#68349 Related: odoo/upgrade#2322 Related: odoo/enterprise#17299 Signed-off-by: Laurent Smet <smetl@users.noreply.github.com>
50 lines
2.0 KiB
Python
50 lines
2.0 KiB
Python
# coding: utf-8
|
|
# Copyright 2016 Vauxoo (https://www.vauxoo.com) <info@vauxoo.com>
|
|
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl).
|
|
|
|
from odoo import models, api, _
|
|
|
|
|
|
class AccountChartTemplate(models.Model):
|
|
_inherit = "account.chart.template"
|
|
|
|
@api.model
|
|
def generate_journals(self, acc_template_ref, company, journals_dict=None):
|
|
"""Set the tax_cash_basis_journal_id on the company"""
|
|
res = super(AccountChartTemplate, self).generate_journals(
|
|
acc_template_ref, company, journals_dict=journals_dict)
|
|
if not self == self.env.ref('l10n_mx.mx_coa'):
|
|
return res
|
|
journal_basis = self.env['account.journal'].search([
|
|
('company_id', '=', company.id),
|
|
('type', '=', 'general'),
|
|
('code', '=', 'CBMX')], limit=1)
|
|
company.write({'tax_cash_basis_journal_id': journal_basis.id})
|
|
return res
|
|
|
|
def _prepare_all_journals(self, acc_template_ref, company, journals_dict=None):
|
|
"""Create the tax_cash_basis_journal_id"""
|
|
res = super(AccountChartTemplate, self)._prepare_all_journals(
|
|
acc_template_ref, company, journals_dict=journals_dict)
|
|
if not self == self.env.ref('l10n_mx.mx_coa'):
|
|
return res
|
|
account = acc_template_ref.get(self.env.ref('l10n_mx.cuenta118_01').id)
|
|
res.append({
|
|
'type': 'general',
|
|
'name': _('Effectively Paid'),
|
|
'code': 'CBMX',
|
|
'company_id': company.id,
|
|
'default_account_id': account,
|
|
'show_on_dashboard': True,
|
|
})
|
|
return res
|
|
|
|
@api.model
|
|
def _prepare_transfer_account_for_direct_creation(self, name, company):
|
|
res = super(AccountChartTemplate, self)._prepare_transfer_account_for_direct_creation(name, company)
|
|
if company.account_fiscal_country_id.code == 'MX':
|
|
xml_id = self.env.ref('l10n_mx.account_tag_102_01').id
|
|
res.setdefault('tag_ids', [])
|
|
res['tag_ids'].append((4, xml_id))
|
|
return res
|