From beb6e1706616dd87c4eb332bb312d1f20bbb90eb Mon Sep 17 00:00:00 2001 From: william-andre Date: Mon, 22 Nov 2021 13:38:23 +0000 Subject: [PATCH] [FIX] account: remove dead code `complete_tax_set` This field was used in version 9.0 [1] to allow users to select their tax rate, but it was removed in version 12 [2] [1] https://github.com/odoo/odoo/commit/c04065abd8f62c9a211c8fa824f5eecf68e61b73 [2] https://github.com/odoo/odoo/commit/87f0d2eefb77bfc6a9a0fa7f7dcd1475c7c34639 closes odoo/odoo#80185 Related: odoo/enterprise#22441 Related: odoo/upgrade#3057 Signed-off-by: Quentin De Paoli --- addons/account/models/chart_template.py | 32 ++----------------- addons/account/models/res_config_settings.py | 2 +- .../views/account_chart_template_views.xml | 1 - addons/l10n_ae/data/l10n_ae_chart_data.xml | 1 - .../l10n_ar/models/account_chart_template.py | 4 +-- .../l10n_at/data/account_chart_template.xml | 1 - addons/l10n_at/models/chart_template.py | 4 +-- addons/l10n_ch/models/chart_template.py | 4 +-- .../l10n_cl/models/account_chart_template.py | 4 +-- addons/l10n_de/models/chart_template.py | 4 +-- .../data/account_chart_template_data.xml | 3 -- addons/l10n_eu_oss/models/chart_template.py | 4 +-- addons/l10n_fr/data/l10n_fr_chart_data.xml | 1 - .../data/l10n_generic_coa_post.xml | 1 - .../l10n_multilang/models/l10n_multilang.py | 4 +-- addons/l10n_mx/models/chart_template.py | 4 +-- .../l10n_nl/models/account_chart_template.py | 4 +-- .../data/account_chart_template_config.xml | 2 -- addons/point_of_sale/models/chart_template.py | 4 +-- .../purchase/tests/test_purchase_invoice.py | 2 +- 20 files changed, 24 insertions(+), 62 deletions(-) diff --git a/addons/account/models/chart_template.py b/addons/account/models/chart_template.py index 583eb3ce97f..282824e452f 100644 --- a/addons/account/models/chart_template.py +++ b/addons/account/models/chart_template.py @@ -94,9 +94,6 @@ class AccountChartTemplate(models.Model): currency_id = fields.Many2one('res.currency', string='Currency', required=True) use_anglo_saxon = fields.Boolean(string="Use Anglo-Saxon accounting", default=False) use_storno_accounting = fields.Boolean(string="Use Storno accounting", default=False) - complete_tax_set = fields.Boolean(string='Complete Set of Taxes', default=True, - help="This boolean helps you to choose if you want to propose to the user to encode the sale and purchase rates or choose from list " - "of taxes. This last choice assumes that the set of tax defined on this template is complete") account_ids = fields.One2many('account.account.template', 'chart_template_id', string='Associated Account Templates') tax_template_ids = fields.One2many('account.tax.template', 'chart_template_id', string='Tax Template List', help='List of all the taxes that have to be installed by the wizard') @@ -196,7 +193,7 @@ class AccountChartTemplate(models.Model): # If we don't have any chart of account on this company, install this chart of account if not company.chart_template_id and not self.existing_accounting(company): for template in self: - template.with_context(default_company_id=company.id)._load(15.0, 15.0, company) + template.with_context(default_company_id=company.id)._load(company) # Install the demo data when the first localization is instanciated on the company if install_demo and self.env.ref('base.module_account').demo: self.with_context( @@ -219,7 +216,7 @@ class AccountChartTemplate(models.Model): # Do not rollback installation of CoA if demo data failed _logger.exception('Error while loading accounting demo data') - def _load(self, sale_tax_rate, purchase_tax_rate, company): + def _load(self, company): """ Installs this chart of accounts on the current company, replacing the existing one if it had already one defined. If some accounting entries had already been made, this function fails instead, triggering a UserError. @@ -278,9 +275,6 @@ class AccountChartTemplate(models.Model): except ValueError: pass - # If the floats for sale/purchase rates have been filled, create templates from them - self._create_tax_templates_from_rates(company.id, sale_tax_rate, purchase_tax_rate) - # Install all the templates objects and generate the real objects acc_template_ref, taxes_ref = self._install_template(company, code_digits=self.code_digits) @@ -359,28 +353,6 @@ class AccountChartTemplate(models.Model): return True return False - def _create_tax_templates_from_rates(self, company_id, sale_tax_rate, purchase_tax_rate): - ''' - This function checks if this chart template is configured as containing a full set of taxes, and if - it's not the case, it creates the templates for account.tax object accordingly to the provided sale/purchase rates. - Then it saves the new tax templates as default taxes to use for this chart template. - - :param company_id: id of the company for which the wizard is running - :param sale_tax_rate: the rate to use for created sales tax - :param purchase_tax_rate: the rate to use for created purchase tax - :return: True - ''' - self.ensure_one() - obj_tax_temp = self.env['account.tax.template'] - all_parents = self._get_chart_parent_ids() - # create tax templates from purchase_tax_rate and sale_tax_rate fields - if not self.complete_tax_set: - ref_taxs = obj_tax_temp.search([('type_tax_use', '=', 'sale'), ('chart_template_id', 'in', all_parents)], order="sequence, id desc", limit=1) - ref_taxs.write({'amount': sale_tax_rate, 'name': _('Tax %.2f%%') % sale_tax_rate, 'description': '%.2f%%' % sale_tax_rate}) - ref_taxs = obj_tax_temp.search([('type_tax_use', '=', 'purchase'), ('chart_template_id', 'in', all_parents)], order="sequence, id desc", limit=1) - ref_taxs.write({'amount': purchase_tax_rate, 'name': _('Tax %.2f%%') % purchase_tax_rate, 'description': '%.2f%%' % purchase_tax_rate}) - return True - def _get_chart_parent_ids(self): """ Returns the IDs of all ancestor charts, including the chart itself. (inverse of child_of operator) diff --git a/addons/account/models/res_config_settings.py b/addons/account/models/res_config_settings.py index 9325cb5a499..936da790035 100644 --- a/addons/account/models/res_config_settings.py +++ b/addons/account/models/res_config_settings.py @@ -157,7 +157,7 @@ class ResConfigSettings(models.TransientModel): if self.env.company == self.company_id \ and self.chart_template_id \ and self.chart_template_id != self.company_id.chart_template_id: - self.chart_template_id._load(15.0, 15.0, self.env.company) + self.chart_template_id._load(self.env.company) @api.depends('company_id') def _compute_has_chart_of_accounts(self): diff --git a/addons/account/views/account_chart_template_views.xml b/addons/account/views/account_chart_template_views.xml index fa0fb6d410c..f2fac4df0f9 100644 --- a/addons/account/views/account_chart_template_views.xml +++ b/addons/account/views/account_chart_template_views.xml @@ -17,7 +17,6 @@ - diff --git a/addons/l10n_ae/data/l10n_ae_chart_data.xml b/addons/l10n_ae/data/l10n_ae_chart_data.xml index c0dadf742d5..384e5fae562 100644 --- a/addons/l10n_ae/data/l10n_ae_chart_data.xml +++ b/addons/l10n_ae/data/l10n_ae_chart_data.xml @@ -10,6 +10,5 @@ 100 - diff --git a/addons/l10n_ar/models/account_chart_template.py b/addons/l10n_ar/models/account_chart_template.py index c4c280b93d2..0e593468c36 100644 --- a/addons/l10n_ar/models/account_chart_template.py +++ b/addons/l10n_ar/models/account_chart_template.py @@ -44,7 +44,7 @@ class AccountChartTemplate(models.Model): } return match.get(chart_template_id) - def _load(self, sale_tax_rate, purchase_tax_rate, company): + def _load(self, company): """ Set companies AFIP Responsibility and Country if AR CoA is installed, also set tax calculation rounding method required in order to properly validate match AFIP invoices. @@ -64,7 +64,7 @@ class AccountChartTemplate(models.Model): # the default VAT type. company.partner_id.l10n_latam_identification_type_id = self.env.ref('l10n_ar.it_cuit') - res = super()._load(sale_tax_rate, purchase_tax_rate, company) + res = super()._load(company) # If Responsable Monotributista remove the default purchase tax if self == self.env.ref('l10n_ar.l10nar_base_chart_template') or \ diff --git a/addons/l10n_at/data/account_chart_template.xml b/addons/l10n_at/data/account_chart_template.xml index 4ab0bdd1728..6f0d2d8a1d7 100644 --- a/addons/l10n_at/data/account_chart_template.xml +++ b/addons/l10n_at/data/account_chart_template.xml @@ -6,7 +6,6 @@ Einheitskontenrahmen Österreich 2010 - diff --git a/addons/l10n_at/models/chart_template.py b/addons/l10n_at/models/chart_template.py index eb0710a1346..3b6da3ee7f7 100644 --- a/addons/l10n_at/models/chart_template.py +++ b/addons/l10n_at/models/chart_template.py @@ -6,8 +6,8 @@ class AccountChartTemplate(models.Model): _inherit = 'account.chart.template' # Write paperformat and report template used on company - def _load(self, sale_tax_rate, purchase_tax_rate, company): - res = super(AccountChartTemplate, self)._load(sale_tax_rate, purchase_tax_rate, company) + def _load(self, company): + res = super(AccountChartTemplate, self)._load(company) if self == self.env.ref('l10n_at.l10n_at_chart_template'): company.write({ 'external_report_layout_id': self.env.ref('l10n_din5008.external_layout_din5008').id, diff --git a/addons/l10n_ch/models/chart_template.py b/addons/l10n_ch/models/chart_template.py index d01eef79395..aff56a1b711 100644 --- a/addons/l10n_ch/models/chart_template.py +++ b/addons/l10n_ch/models/chart_template.py @@ -6,8 +6,8 @@ class AccountChartTemplate(models.Model): _inherit = 'account.chart.template' # Write paperformat and report template used on company - def _load(self, sale_tax_rate, purchase_tax_rate, company): - res = super(AccountChartTemplate, self)._load(sale_tax_rate, purchase_tax_rate, company) + def _load(self, company): + res = super(AccountChartTemplate, self)._load(company) if self == self.env.ref('l10n_ch.l10nch_chart_template'): company.write({ 'external_report_layout_id': self.env.ref('l10n_din5008.external_layout_din5008').id, diff --git a/addons/l10n_cl/models/account_chart_template.py b/addons/l10n_cl/models/account_chart_template.py index 4996bad35dc..9641dfbbc34 100644 --- a/addons/l10n_cl/models/account_chart_template.py +++ b/addons/l10n_cl/models/account_chart_template.py @@ -7,9 +7,9 @@ from odoo.http import request class AccountChartTemplate(models.Model): _inherit = 'account.chart.template' - def _load(self, sale_tax_rate, purchase_tax_rate, company): + def _load(self, company): """ Set tax calculation rounding method required in Chilean localization""" - res = super()._load(sale_tax_rate, purchase_tax_rate, company) + res = super()._load(company) if company.account_fiscal_country_id.code == 'CL': company.write({'tax_calculation_rounding_method': 'round_globally'}) return res diff --git a/addons/l10n_de/models/chart_template.py b/addons/l10n_de/models/chart_template.py index 32650e729ad..746d274c006 100644 --- a/addons/l10n_de/models/chart_template.py +++ b/addons/l10n_de/models/chart_template.py @@ -6,8 +6,8 @@ class AccountChartTemplate(models.Model): _inherit = 'account.chart.template' # Write paperformat and report template used on company - def _load(self, sale_tax_rate, purchase_tax_rate, company): - res = super(AccountChartTemplate, self)._load(sale_tax_rate, purchase_tax_rate, company) + def _load(self, company): + res = super(AccountChartTemplate, self)._load(company) if self in [ self.env.ref('l10n_de_skr03.l10n_de_chart_template', raise_if_not_found=False), self.env.ref('l10n_de_skr04.l10n_chart_de_skr04', raise_if_not_found=False) diff --git a/addons/l10n_es/data/account_chart_template_data.xml b/addons/l10n_es/data/account_chart_template_data.xml index bdcab5b37b0..f5cbfaa44ce 100644 --- a/addons/l10n_es/data/account_chart_template_data.xml +++ b/addons/l10n_es/data/account_chart_template_data.xml @@ -13,7 +13,6 @@ PGCE PYMEs 2008 - 570 572 @@ -24,7 +23,6 @@ PGCE entidades sin ánimo de lucro 2008 - 570 572 @@ -35,7 +33,6 @@ PGCE completo 2008 - 570 572 diff --git a/addons/l10n_eu_oss/models/chart_template.py b/addons/l10n_eu_oss/models/chart_template.py index 59d140ff104..84723291122 100644 --- a/addons/l10n_eu_oss/models/chart_template.py +++ b/addons/l10n_eu_oss/models/chart_template.py @@ -6,8 +6,8 @@ from odoo import models class AccountChartTemplate(models.Model): _inherit = 'account.chart.template' - def _load(self, sale_tax_rate, purchase_tax_rate, company): - rslt = super()._load(sale_tax_rate, purchase_tax_rate, company) + def _load(self, company): + rslt = super()._load(company) if company.account_fiscal_country_id in self.env.ref('base.europe').country_ids: company._map_eu_taxes() diff --git a/addons/l10n_fr/data/l10n_fr_chart_data.xml b/addons/l10n_fr/data/l10n_fr_chart_data.xml index 396a0d4153a..edaca5a5ef5 100644 --- a/addons/l10n_fr/data/l10n_fr_chart_data.xml +++ b/addons/l10n_fr/data/l10n_fr_chart_data.xml @@ -8,7 +8,6 @@ 512 53 58 - diff --git a/addons/l10n_generic_coa/data/l10n_generic_coa_post.xml b/addons/l10n_generic_coa/data/l10n_generic_coa_post.xml index 3fe0005ed45..e46d7e89641 100644 --- a/addons/l10n_generic_coa/data/l10n_generic_coa_post.xml +++ b/addons/l10n_generic_coa/data/l10n_generic_coa_post.xml @@ -10,7 +10,6 @@ - diff --git a/addons/l10n_multilang/models/l10n_multilang.py b/addons/l10n_multilang/models/l10n_multilang.py index e52f1436035..8b5cc601e48 100644 --- a/addons/l10n_multilang/models/l10n_multilang.py +++ b/addons/l10n_multilang/models/l10n_multilang.py @@ -12,8 +12,8 @@ _logger = logging.getLogger(__name__) class AccountChartTemplate(models.Model): _inherit = 'account.chart.template' - def _load(self, sale_tax_rate, purchase_tax_rate, company): - res = super(AccountChartTemplate, self)._load(sale_tax_rate, purchase_tax_rate, company) + def _load(self, company): + res = super(AccountChartTemplate, self)._load(company) # Copy chart of account translations when loading chart of account for chart_template in self.filtered('spoken_languages'): external_id = self.env['ir.model.data'].search([ diff --git a/addons/l10n_mx/models/chart_template.py b/addons/l10n_mx/models/chart_template.py index 830f11ae240..ce5c99afe9d 100644 --- a/addons/l10n_mx/models/chart_template.py +++ b/addons/l10n_mx/models/chart_template.py @@ -58,8 +58,8 @@ class AccountChartTemplate(models.Model): res['tag_ids'] = [(6, 0, self.env.ref('l10n_mx.account_tag_102_01').ids)] return res - def _load(self, sale_tax_rate, purchase_tax_rate, company): - res = super()._load(sale_tax_rate, purchase_tax_rate, company) + def _load(self, company): + res = super()._load(company) if self == self.env.ref('l10n_mx.mx_coa'): company.account_journal_payment_debit_account_id.tag_ids = [(6, 0, self.env.ref('l10n_mx.account_tag_102_01').ids)] company.account_journal_payment_credit_account_id.tag_ids = [(6, 0, self.env.ref('l10n_mx.account_tag_102_01').ids)] diff --git a/addons/l10n_nl/models/account_chart_template.py b/addons/l10n_nl/models/account_chart_template.py index 63d19fc4eb1..a8d1fe74534 100644 --- a/addons/l10n_nl/models/account_chart_template.py +++ b/addons/l10n_nl/models/account_chart_template.py @@ -6,9 +6,9 @@ from odoo import api, Command, models class AccountChartTemplate(models.Model): _inherit = 'account.chart.template' - def _load(self, sale_tax_rate, purchase_tax_rate, company): + def _load(self, company): # Add tag to 999999 account - res = super(AccountChartTemplate, self)._load(sale_tax_rate, purchase_tax_rate, company) + res = super(AccountChartTemplate, self)._load(company) if company.account_fiscal_country_id.code == 'NL': account = self.env['account.account'].search([('code', '=', '999999'), ('company_id', '=', self.env.company.id)]) if account: diff --git a/addons/l10n_ua/data/account_chart_template_config.xml b/addons/l10n_ua/data/account_chart_template_config.xml index 8351286f7a4..3f21c6dad6f 100644 --- a/addons/l10n_ua/data/account_chart_template_config.xml +++ b/addons/l10n_ua/data/account_chart_template_config.xml @@ -6,7 +6,6 @@ - @@ -21,7 +20,6 @@ - diff --git a/addons/point_of_sale/models/chart_template.py b/addons/point_of_sale/models/chart_template.py index 28c9760ddd8..6feafdec556 100644 --- a/addons/point_of_sale/models/chart_template.py +++ b/addons/point_of_sale/models/chart_template.py @@ -5,7 +5,7 @@ from odoo import api, models class AccountChartTemplate(models.Model): _inherit = 'account.chart.template' - def _load(self, sale_tax_rate, purchase_tax_rate, company): + def _load(self, company): """Remove the payment methods that are created for the company before installing the chart of accounts. Keeping these existing pos.payment.method records interferes with the installation of chart of accounts @@ -13,6 +13,6 @@ class AccountChartTemplate(models.Model): deleted during the loading of chart of accounts. """ self.env['pos.payment.method'].search([('company_id', '=', company.id)]).unlink() - result = super(AccountChartTemplate, self)._load(sale_tax_rate, purchase_tax_rate, company) + result = super(AccountChartTemplate, self)._load(company) self.env['pos.config'].post_install_pos_localisation(companies=company) return result diff --git a/addons/purchase/tests/test_purchase_invoice.py b/addons/purchase/tests/test_purchase_invoice.py index 0e9debf7f05..eabfdbdf23f 100644 --- a/addons/purchase/tests/test_purchase_invoice.py +++ b/addons/purchase/tests/test_purchase_invoice.py @@ -335,7 +335,7 @@ class TestPurchaseToInvoice(AccountTestInvoicingCommon): company_b = self.env['res.company'].create({ 'name': 'Company B', }) - self.env.ref('l10n_generic_coa.configurable_chart_template')._load(15.0, 15.0, company_b) + self.env.ref('l10n_generic_coa.configurable_chart_template')._load(company_b) partner = self.env['res.partner'].create({ 'name': 'AAAAA',