[IMP] account: remove account_fiscal_country_* config parameter
This config parameter was used in order to choose another country than the company's to select the tax report. It is now replaced by a new account_tax_fiscal_country_id field in account_reports. closes odoo/odoo#55308 Related: odoo/enterprise#12156 Related: odoo/upgrade#1624 Signed-off-by: Laurent Smet <smetl@users.noreply.github.com>
This commit is contained in:
@@ -10,9 +10,17 @@ from odoo import api, SUPERUSER_ID
|
||||
|
||||
SYSCOHADA_LIST = ['BJ', 'BF', 'CM', 'CF', 'KM', 'CG', 'CI', 'GA', 'GN', 'GW', 'GQ', 'ML', 'NE', 'CD', 'SN', 'TD', 'TG']
|
||||
|
||||
def _auto_install_l10n(cr, registry):
|
||||
def _set_fiscal_country(env):
|
||||
""" Sets the fiscal country on existing companies when installing the module.
|
||||
That field is an editable computed field. It doesn't automatically get computed
|
||||
on existing records by the ORM when installing the module, so doing that by hand
|
||||
ensures existing records will get a value for it if needed.
|
||||
"""
|
||||
env['res.company'].search([]).compute_account_tax_fiscal_country()
|
||||
|
||||
|
||||
def _auto_install_l10n(env):
|
||||
#check the country of the main company (only) and eventually load some module needed in that country
|
||||
env = api.Environment(cr, SUPERUSER_ID, {})
|
||||
country_code = env.company.country_id.code
|
||||
if country_code:
|
||||
#auto install localization module(s) if available
|
||||
@@ -63,3 +71,8 @@ def _auto_install_l10n(cr, registry):
|
||||
module_list.append('account_bank_statement_import_camt')
|
||||
module_ids = env['ir.module.module'].search([('name', 'in', module_list), ('state', '=', 'uninstalled')])
|
||||
module_ids.sudo().button_install()
|
||||
|
||||
def _account_post_init(cr, registry):
|
||||
env = api.Environment(cr, SUPERUSER_ID, {})
|
||||
_auto_install_l10n(env)
|
||||
_set_fiscal_country(env)
|
||||
|
||||
@@ -93,5 +93,5 @@ You could use this simplified accounting in case you work with an (external) acc
|
||||
'installable': True,
|
||||
'application': True,
|
||||
'auto_install': False,
|
||||
'post_init_hook': '_auto_install_l10n',
|
||||
'post_init_hook': '_account_post_init',
|
||||
}
|
||||
|
||||
@@ -2696,7 +2696,7 @@ class AccountMoveLine(models.Model):
|
||||
company_currency_id = fields.Many2one(related='company_id.currency_id', string='Company Currency',
|
||||
readonly=True, store=True,
|
||||
help='Utility field to express amount currency')
|
||||
country_id = fields.Many2one(comodel_name='res.country', related='move_id.company_id.country_id')
|
||||
tax_fiscal_country_id = fields.Many2one(comodel_name='res.country', related='move_id.company_id.account_tax_fiscal_country_id')
|
||||
account_id = fields.Many2one('account.account', string='Account',
|
||||
index=True, ondelete="cascade",
|
||||
domain="[('deprecated', '=', False), ('company_id', '=', 'company_id'),('is_off_balance', '=', False)]",
|
||||
|
||||
@@ -91,7 +91,7 @@ class AccountTax(models.Model):
|
||||
help="Account used to transition the tax amount for cash basis taxes. It will contain the tax amount as long as the original invoice has not been reconciled ; at reconciliation, this amount cancelled on this account and put on the regular tax account.")
|
||||
invoice_repartition_line_ids = fields.One2many(string="Repartition for Invoices", comodel_name="account.tax.repartition.line", inverse_name="invoice_tax_id", copy=True, help="Repartition when the tax is used on an invoice")
|
||||
refund_repartition_line_ids = fields.One2many(string="Repartition for Refund Invoices", comodel_name="account.tax.repartition.line", inverse_name="refund_tax_id", copy=True, help="Repartition when the tax is used on a refund")
|
||||
country_id = fields.Many2one(string='Country', comodel_name='res.country', related='company_id.country_id', help="Technical field used to restrict the domain of account tags for tax repartition lines created for this tax.")
|
||||
tax_fiscal_country_id = fields.Many2one(string='Fiscal Country', comodel_name='res.country', related='company_id.account_tax_fiscal_country_id', help="Technical field used to restrict the domain of account tags for tax repartition lines created for this tax.")
|
||||
|
||||
_sql_constraints = [
|
||||
('name_company_uniq', 'unique(name, company_id, type_tax_use, tax_scope)', 'Tax names must be unique !'),
|
||||
@@ -108,15 +108,15 @@ class AccountTax(models.Model):
|
||||
if 'refund_repartition_line_ids' in fields_list:
|
||||
# We write on the related country_id field so that the field is recomputed. Without that, it will stay empty until we save the record.
|
||||
rslt['refund_repartition_line_ids'] = [
|
||||
(0, 0, {'repartition_type': 'base', 'factor_percent': 100.0, 'tag_ids': [], 'company_id': company_id, 'country_id': company.country_id.id}),
|
||||
(0, 0, {'repartition_type': 'tax', 'factor_percent': 100.0, 'tag_ids': [], 'company_id': company_id, 'country_id': company.country_id.id}),
|
||||
(0, 0, {'repartition_type': 'base', 'factor_percent': 100.0, 'tag_ids': [], 'company_id': company_id, 'tax_fiscal_country_id': company.country_id.id}),
|
||||
(0, 0, {'repartition_type': 'tax', 'factor_percent': 100.0, 'tag_ids': [], 'company_id': company_id, 'tax_fiscal_country_id': company.country_id.id}),
|
||||
]
|
||||
|
||||
if 'invoice_repartition_line_ids' in fields_list:
|
||||
# We write on the related country_id field so that the field is recomputed. Without that, it will stay empty until we save the record.
|
||||
rslt['invoice_repartition_line_ids'] = [
|
||||
(0, 0, {'repartition_type': 'base', 'factor_percent': 100.0, 'tag_ids': [], 'company_id': company_id, 'country_id': company.country_id.id}),
|
||||
(0, 0, {'repartition_type': 'tax', 'factor_percent': 100.0, 'tag_ids': [], 'company_id': company_id, 'country_id': company.country_id.id}),
|
||||
(0, 0, {'repartition_type': 'base', 'factor_percent': 100.0, 'tag_ids': [], 'company_id': company_id, 'tax_fiscal_country_id': company.country_id.id}),
|
||||
(0, 0, {'repartition_type': 'tax', 'factor_percent': 100.0, 'tag_ids': [], 'company_id': company_id, 'tax_fiscal_country_id': company.country_id.id}),
|
||||
]
|
||||
|
||||
return rslt
|
||||
@@ -636,7 +636,7 @@ class AccountTaxRepartitionLine(models.Model):
|
||||
check_company=True,
|
||||
help="The tax set to apply this repartition on refund invoices. Mutually exclusive with invoice_tax_id")
|
||||
tax_id = fields.Many2one(comodel_name='account.tax', compute='_compute_tax_id')
|
||||
country_id = fields.Many2one(string="Country", comodel_name='res.country', related='company_id.country_id', help="Technical field used to restrict tags domain in form view.")
|
||||
tax_fiscal_country_id = fields.Many2one(string="Fiscal Country", comodel_name='res.country', related='company_id.account_tax_fiscal_country_id', help="Technical field used to restrict tags domain in form view.")
|
||||
company_id = fields.Many2one(string="Company", comodel_name='res.company', compute="_compute_company", store=True, help="The company this repartition line belongs to.")
|
||||
sequence = fields.Integer(string="Sequence", default=1, help="The order in which display and match repartition lines. For refunds to work properly, invoice repartition lines should be arranged in the same order as the credit note repartition lines they correspond to.")
|
||||
use_in_tax_closing = fields.Boolean(string="Tax Closing Entry")
|
||||
|
||||
@@ -77,6 +77,7 @@ class ResCompany(models.Model):
|
||||
property_stock_valuation_account_id = fields.Many2one('account.account', string="Account Template for Stock Valuation")
|
||||
bank_journal_ids = fields.One2many('account.journal', 'company_id', domain=[('type', '=', 'bank')], string='Bank Journals')
|
||||
tax_exigibility = fields.Boolean(string='Use Cash Basis')
|
||||
account_tax_fiscal_country_id = fields.Many2one('res.country', string="Fiscal Country", compute='compute_account_tax_fiscal_country', store=True, readonly=False, help="The country to use the tax reports from for this company")
|
||||
|
||||
incoterm_id = fields.Many2one('account.incoterms', string='Default incoterm',
|
||||
help='International Commercial Terms are a series of predefined commercial terms used in international transactions.')
|
||||
@@ -147,6 +148,11 @@ class ResCompany(models.Model):
|
||||
if rec.fiscalyear_last_day > max_day:
|
||||
raise ValidationError(_("Invalid fiscal year last day"))
|
||||
|
||||
@api.depends('country_id')
|
||||
def compute_account_tax_fiscal_country(self):
|
||||
for record in self:
|
||||
record.account_tax_fiscal_country_id = record.country_id
|
||||
|
||||
def get_and_update_account_invoice_onboarding_state(self):
|
||||
""" This method is called on the controller rendering method and ensures that the animations
|
||||
are displayed only one time. """
|
||||
@@ -244,6 +250,7 @@ class ResCompany(models.Model):
|
||||
if values.get('bank_account_code_prefix'):
|
||||
new_bank_code = values.get('bank_account_code_prefix') or company.bank_account_code_prefix
|
||||
company.reflect_code_prefix_change(company.bank_account_code_prefix, new_bank_code)
|
||||
|
||||
if values.get('cash_account_code_prefix'):
|
||||
new_cash_code = values.get('cash_account_code_prefix') or company.cash_account_code_prefix
|
||||
company.reflect_code_prefix_change(company.cash_account_code_prefix, new_cash_code)
|
||||
@@ -589,16 +596,3 @@ class ResCompany(models.Model):
|
||||
results_by_journal['results'].append(rslt)
|
||||
|
||||
return results_by_journal
|
||||
|
||||
def get_fiscal_country(self):
|
||||
""" Returns the country to be used for this company's tax report.
|
||||
By default, it'll be the one from the address; but a config parameter
|
||||
may be used for each company to customize that behavior.
|
||||
"""
|
||||
self.ensure_one()
|
||||
|
||||
fiscal_country_key = 'account_fiscal_country_%s' % self.id
|
||||
forced_country_code = self.env['ir.config_parameter'].sudo().get_param(fiscal_country_key)
|
||||
forced_country = forced_country_code and self.env['res.country'].search([('code', 'ilike', forced_country_code)], limit=1)
|
||||
|
||||
return forced_country or self.country_id
|
||||
|
||||
@@ -953,8 +953,8 @@
|
||||
<field name="credit"
|
||||
sum="Total Credit"
|
||||
attrs="{'invisible': [('display_type', 'in', ('line_section', 'line_note'))]}"/>
|
||||
<field name="country_id" invisible="1"/>
|
||||
<field name="tax_tag_ids" widget="many2many_tags" string="Tax Grids" optional="show" domain="[('country_id', '=', country_id), ('applicability', '=', 'taxes')]"/>
|
||||
<field name="tax_fiscal_country_id" invisible="1"/>
|
||||
<field name="tax_tag_ids" widget="many2many_tags" string="Tax Grids" optional="show" domain="[('country_id', '=', tax_fiscal_country_id), ('applicability', '=', 'taxes')]"/>
|
||||
|
||||
<!-- Buttons -->
|
||||
<button name="action_automatic_entry"
|
||||
|
||||
@@ -27,9 +27,9 @@
|
||||
<field name="factor_percent" attrs="{'invisible': [('repartition_type', '=', 'base')]}"/>
|
||||
<field name="repartition_type"/>
|
||||
<field name="account_id" attrs="{'invisible': [('repartition_type', '=', 'base')]}" options="{'no_create': True}"/>
|
||||
<field name="tag_ids" widget="many2many_tags" options="{'no_create': True}" domain="[('applicability', '=', 'taxes'), ('country_id', '=', country_id)]"/>
|
||||
<field name="tag_ids" widget="many2many_tags" options="{'no_create': True}" domain="[('applicability', '=', 'taxes'), ('country_id', '=', tax_fiscal_country_id)]"/>
|
||||
<field name="use_in_tax_closing" optional="hidden" />
|
||||
<field name="country_id" invisible="1"/>
|
||||
<field name="tax_fiscal_country_id" invisible="1"/>
|
||||
<field name="company_id" invisible="1"/>
|
||||
</tree>
|
||||
</field>
|
||||
@@ -133,7 +133,7 @@
|
||||
<notebook>
|
||||
<page string="Definition" name="definition">
|
||||
<div attrs="{'invisible': [('amount_type', '=', 'group')]}">
|
||||
<field name="country_id" invisible="1"/>
|
||||
<field name="tax_fiscal_country_id" invisible="1"/>
|
||||
<group string="Repartition for Invoices">
|
||||
<field name="invoice_repartition_line_ids" nolabel="1" context="{'default_company_id': company_id}"/>
|
||||
</group>
|
||||
|
||||
Reference in New Issue
Block a user