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

[11.0] account: "Could not install new chart of account as there are already accounting entries existing" #1485

Closed
miquelalzanillas opened this issue Aug 13, 2018 · 5 comments

Comments

@miquelalzanillas
Copy link

Impacted versions:
10.0 -> 11.0

Steps to reproduce:
python migrate.py --config=odoo.conf --database=odoo --run-migrations=10.0,11.0

Current behavior:

_2018-08-13 08:14:55,008 3812 INFO odoo_migrated odoo.modules.loading: loading stock_account/security/stock_account_security.xml
2018-08-13 08:14:55,078 3812 INFO odoo_migrated odoo.models: Actual recompute of field res.users.share for 9 recs.
2018-08-13 08:14:55,093 3812 INFO odoo_migrated odoo.models: Actual recompute of field res.partner.partner_share for 9 recs.
2018-08-13 08:14:55,471 3812 INFO odoo_migrated odoo.modules.loading: loading stock_account/security/ir.model.access.csv
2018-08-13 08:14:55,600 3812 INFO odoo_migrated odoo.modules.loading: loading stock_account/wizard/stock_change_standard_price_views.xml
2018-08-13 08:14:55,631 3812 INFO odoo_migrated odoo.models.unlink: User #1 deleted ir.translation records with IDs: [1459250]
2018-08-13 08:14:55,649 3812 INFO odoo_migrated odoo.modules.loading: loading stock_account/data/stock_account_data.xml
2018-08-13 08:14:55,663 3812 INFO odoo_migrated odoo.modules.loading: loading stock_account/views/stock_account_views.xml
2018-08-13 08:14:55,920 3812 INFO odoo_migrated odoo.modules.loading: loading stock_account/views/res_config_settings_views.xml
2018-08-13 08:14:56,073 3812 INFO odoo_migrated odoo.modules.loading: loading stock_account/data/product_data.xml
2018-08-13 08:14:56,082 3812 INFO odoo_migrated odoo.modules.loading: loading stock_account/views/product_views.xml
2018-08-13 08:14:56,227 3812 INFO odoo_migrated odoo.modules.loading: loading stock_account/data/stock_account_data_post_install.yml
2018-08-13 08:14:56,249 3812 INFO odoo_migrated odoo.addons.base.ir.ir_translation: module stock_account: loading base translation file ca for language ca_ES
2018-08-13 08:14:56,250 3812 INFO odoo_migrated odoo.tools.translate: loading /var/tmp/openupgrade/11.0/addons/stock_account/i18n/ca.po
2018-08-13 08:14:56,395 3812 INFO odoo_migrated odoo.addons.base.ir.ir_translation: module stock_account: no translation for language ca_ES
2018-08-13 08:14:56,396 3812 INFO odoo_migrated odoo.addons.base.ir.ir_translation: module stock_account: loading translation file (es) for language es_ES
2018-08-13 08:14:56,396 3812 INFO odoo_migrated odoo.tools.translate: loading /var/tmp/openupgrade/11.0/addons/stock_account/i18n/es.po
2018-08-13 08:14:57,007 3812 INFO odoo_migrated odoo.models: Actual recompute of field ir.module.module.menus_by_module for 1 recs.
2018-08-13 08:14:57,559 3812 INFO odoo_migrated odoo.modules.registry: module base_vat_autocomplete: creating or updating database tables
2018-08-13 08:14:57,620 3812 INFO odoo_migrated odoo.addons.auth_crypt.models.res_users: Hashing passwords, may be slow for databases with many users...
2018-08-13 08:14:58,074 3812 INFO odoo_migrated odoo.modules.loading: loading base_vat_autocomplete/views/res_partner_views.xml
2018-08-13 08:14:58,198 3812 INFO odoo_migrated odoo.addons.base.ir.ir_ui_view: El campo notify_email no existe

Error de contexto:
Vista res.partner.vat.inherit
[view_id: 4358, xml_id: n/a, model: res.partner, parent_id: 129]
2018-08-13 08:14:58,249 3812 INFO odoo_migrated odoo.modules.loading: loading base_vat_autocomplete/views/res_company_view.xml
2018-08-13 08:14:58,306 3812 INFO odoo_migrated odoo.addons.base.ir.ir_translation: module base_vat_autocomplete: loading base translation file ca for language ca_ES
2018-08-13 08:14:58,306 3812 INFO odoo_migrated odoo.tools.translate: loading /var/tmp/openupgrade/11.0/addons/base_vat_autocomplete/i18n/ca.po
2018-08-13 08:14:58,344 3812 INFO odoo_migrated odoo.addons.base.ir.ir_translation: module base_vat_autocomplete: no translation for language ca_ES
2018-08-13 08:14:58,345 3812 INFO odoo_migrated odoo.addons.base.ir.ir_translation: module base_vat_autocomplete: loading translation file (es) for language es_ES
2018-08-13 08:14:58,346 3812 INFO odoo_migrated odoo.tools.translate: loading /var/tmp/openupgrade/11.0/addons/base_vat_autocomplete/i18n/es.po
2018-08-13 08:14:58,544 3812 INFO odoo_migrated odoo.addons.base.ir.ir_ui_view: El campo notify_email no existe

Error de contexto:
Vista res.partner.vat.inherit
[view_id: 4358, xml_id: base_vat_autocomplete.view_partner_form, model: res.partner, parent_id: 129]
2018-08-13 08:14:58,594 3812 INFO odoo_migrated odoo.models: Actual recompute of field ir.module.module.reports_by_module for 1 recs.
2018-08-13 08:14:59,113 3812 INFO odoo_migrated odoo.modules.registry: module hr_timesheet_attendance: creating or updating database tables
2018-08-13 08:14:59,157 3812 INFO odoo_migrated odoo.modules.loading: loading hr_timesheet_attendance/security/ir.model.access.csv
2018-08-13 08:14:59,182 3812 INFO odoo_migrated odoo.modules.loading: loading hr_timesheet_attendance/report/hr_timesheet_attendance_report_view.xml
2018-08-13 08:14:59,264 3812 INFO odoo_migrated odoo.addons.base.ir.ir_translation: module hr_timesheet_attendance: loading base translation file ca for language ca_ES
2018-08-13 08:14:59,264 3812 INFO odoo_migrated odoo.tools.translate: loading /var/tmp/openupgrade/11.0/addons/hr_timesheet_attendance/i18n/ca.po
2018-08-13 08:14:59,337 3812 INFO odoo_migrated odoo.addons.base.ir.ir_translation: module hr_timesheet_attendance: no translation for language ca_ES
2018-08-13 08:14:59,339 3812 INFO odoo_migrated odoo.addons.base.ir.ir_translation: module hr_timesheet_attendance: loading translation file (es) for language es_ES
2018-08-13 08:14:59,339 3812 INFO odoo_migrated odoo.tools.translate: loading /var/tmp/openupgrade/11.0/addons/hr_timesheet_attendance/i18n/es.po
2018-08-13 08:14:59,471 3812 INFO odoo_migrated odoo.models: Actual recompute of field ir.module.module.menus_by_module for 1 recs.
2018-08-13 08:14:59,924 3812 INFO odoo_migrated odoo.modules.registry: module l10n_es: creating or updating database tables
2018-08-13 08:14:59,948 3812 INFO odoo_migrated odoo.modules.loading: loading l10n_es/data/account_group.xml
2018-08-13 08:15:03,048 3812 INFO odoo_migrated odoo.modules.loading: loading l10n_es/data/account_chart_template_data.xml
2018-08-13 08:15:03,093 3812 INFO odoo_migrated odoo.modules.loading: loading l10n_es/data/account_account_template_common_data.xml
2018-08-13 08:15:05,709 3812 INFO odoo_migrated odoo.modules.loading: loading l10n_es/data/account_account_template_pymes_data.xml
2018-08-13 08:15:05,877 3812 INFO odoo_migrated odoo.modules.loading: loading l10n_es/data/account_account_template_assoc_data.xml
2018-08-13 08:15:06,170 3812 INFO odoo_migrated odoo.modules.loading: loading l10n_es/data/account_account_template_full_data.xml
2018-08-13 08:15:06,780 3812 INFO odoo_migrated odoo.modules.loading: loading l10n_es/data/account_chart_template_account_account_link.xml
2018-08-13 08:15:06,790 3812 INFO odoo_migrated odoo.modules.loading: loading l10n_es/data/account_data.xml
2018-08-13 08:15:06,861 3812 INFO odoo_migrated odoo.modules.loading: loading l10n_es/data/account_tax_data.xml
2018-08-13 08:15:07,604 3812 INFO odoo_migrated odoo.modules.loading: loading l10n_es/data/account_fiscal_position_template_data.xml
2018-08-13 08:15:09,114 3812 INFO odoo_migrated odoo.modules.loading: loading l10n_es/data/account_chart_template_data.yml
2018-08-13 08:15:09,360 3812 ERROR odoo_migrated odoo.tools.yaml_import: ('Could not install new chart of account as there are already accounting entries existing', '')
Traceback (most recent call last):
File "/var/tmp/openupgrade/11.0/server/odoo/tools/yaml_import.py", line 797, in process
self._process_node(node)
File "/var/tmp/openupgrade/11.0/server/odoo/tools/yaml_import.py", line 810, in process_node
self.process_python(node)
File "/var/tmp/openupgrade/11.0/server/odoo/tools/yaml_import.py", line 601, in process_python
unsafe_eval(code_obj, {'ref': self.get_id}, code_context)
File "/var/tmp/openupgrade/11.0/addons/l10n_es/data/account_chart_template_data.yml", line 3, in
self[0].try_loading_for_current_company()
File "", line 2, in try_loading_for_current_company
File "/var/tmp/openupgrade/11.0/server/odoo/api.py", line 369, in loop
result = [method(rec, *args, **kwargs) for rec in self]
File "/var/tmp/openupgrade/11.0/server/odoo/api.py", line 369, in
result = [method(rec, *args, **kwargs) for rec in self]
File "/var/tmp/openupgrade/11.0/addons/account/models/chart_template.py", line 146, in try_loading_for_current_company
wizard.execute()
File "/var/tmp/openupgrade/11.0/addons/account/models/chart_template.py", line 873, in execute
raise UserError(
('Could not install new chart of account as there are already accounting entries existing'))
odoo.exceptions.UserError: ('Could not install new chart of account as there are already accounting entries existing', '')
2018-08-13 08:15:09,383 3812 WARNING odoo_migrated odoo.modules.loading: Transient module states were reset
2018-08-13 08:15:09,386 3812 ERROR odoo_migrated odoo.modules.registry: Failed to load registry
Traceback (most recent call last):
File "/var/tmp/openupgrade/11.0/server/odoo/modules/registry.py", line 85, in new
odoo.modules.load_modules(registry._db, force_demo, status, update_module)
File "/var/tmp/openupgrade/11.0/server/odoo/modules/loading.py", line 451, in load_modules
force, status, report, loaded_modules, update_module, models_to_check, upg_registry)
File "/var/tmp/openupgrade/11.0/server/odoo/modules/loading.py", line 337, in load_marked_modules
upg_registry=upg_registry,
File "/var/tmp/openupgrade/11.0/server/odoo/modules/loading.py", line 207, in load_module_graph
_load_data(cr, module_name, idref, mode, kind='data')
File "/var/tmp/openupgrade/11.0/server/odoo/modules/loading.py", line 98, in _load_data
tools.convert_file(cr, module_name, filename, idref, mode, noupdate, kind, report)
File "/var/tmp/openupgrade/11.0/server/odoo/tools/convert.py", line 793, in convert_file
convert_yaml_import(cr, module, fp, kind, idref, mode, noupdate, report)
File "/var/tmp/openupgrade/11.0/server/odoo/tools/yaml_import.py", line 854, in yaml_import
yaml_interpreter.process(yaml_string)
File "/var/tmp/openupgrade/11.0/server/odoo/tools/yaml_import.py", line 797, in process
self._process_node(node)
File "/var/tmp/openupgrade/11.0/server/odoo/tools/yaml_import.py", line 810, in process_node
self.process_python(node)
File "/var/tmp/openupgrade/11.0/server/odoo/tools/yaml_import.py", line 601, in process_python
unsafe_eval(code_obj, {'ref': self.get_id}, code_context)
File "/var/tmp/openupgrade/11.0/addons/l10n_es/data/account_chart_template_data.yml", line 3, in
self[0].try_loading_for_current_company()
File "", line 2, in try_loading_for_current_company
File "/var/tmp/openupgrade/11.0/server/odoo/api.py", line 369, in loop
result = [method(rec, *args, **kwargs) for rec in self]
File "/var/tmp/openupgrade/11.0/server/odoo/api.py", line 369, in
result = [method(rec, *args, **kwargs) for rec in self]
File "/var/tmp/openupgrade/11.0/addons/account/models/chart_template.py", line 146, in try_loading_for_current_company
wizard.execute()
File "/var/tmp/openupgrade/11.0/addons/account/models/chart_template.py", line 873, in execute
raise UserError(
('Could not install new chart of account as there are already accounting entries existing'))
odoo.exceptions.UserError: ('Could not install new chart of account as there are already accounting entries existing', '')
2018-08-13 08:15:09,388 3812 CRITICAL odoo_migrated odoo.service.server: Failed to initialize database odoo_migrated.
Traceback (most recent call last):
File "/var/tmp/openupgrade/11.0/server/odoo/service/server.py", line 925, in preload_registries
registry = Registry.new(dbname, update_module=update_module)
File "/var/tmp/openupgrade/11.0/server/odoo/modules/registry.py", line 85, in new
odoo.modules.load_modules(registry._db, force_demo, status, update_module)
File "/var/tmp/openupgrade/11.0/server/odoo/modules/loading.py", line 451, in load_modules
force, status, report, loaded_modules, update_module, models_to_check, upg_registry)
File "/var/tmp/openupgrade/11.0/server/odoo/modules/loading.py", line 337, in load_marked_modules
upg_registry=upg_registry,
File "/var/tmp/openupgrade/11.0/server/odoo/modules/loading.py", line 207, in load_module_graph
_load_data(cr, module_name, idref, mode, kind='data')
File "/var/tmp/openupgrade/11.0/server/odoo/modules/loading.py", line 98, in _load_data
tools.convert_file(cr, module_name, filename, idref, mode, noupdate, kind, report)
File "/var/tmp/openupgrade/11.0/server/odoo/tools/convert.py", line 793, in convert_file
convert_yaml_import(cr, module, fp, kind, idref, mode, noupdate, report)
File "/var/tmp/openupgrade/11.0/server/odoo/tools/yaml_import.py", line 854, in yaml_import
yaml_interpreter.process(yaml_string)
File "/var/tmp/openupgrade/11.0/server/odoo/tools/yaml_import.py", line 797, in process
self.process_node(node)
File "/var/tmp/openupgrade/11.0/server/odoo/tools/yaml_import.py", line 810, in process_node
self.process_python(node)
File "/var/tmp/openupgrade/11.0/server/odoo/tools/yaml_import.py", line 601, in process_python
unsafe_eval(code_obj, {'ref': self.get_id}, code_context)
File "/var/tmp/openupgrade/11.0/addons/l10n_es/data/account_chart_template_data.yml", line 3, in
self[0].try_loading_for_current_company()
File "", line 2, in try_loading_for_current_company
File "/var/tmp/openupgrade/11.0/server/odoo/api.py", line 369, in loop
result = [method(rec, *args, **kwargs) for rec in self]
File "/var/tmp/openupgrade/11.0/server/odoo/api.py", line 369, in
result = [method(rec, *args, **kwargs) for rec in self]
File "/var/tmp/openupgrade/11.0/addons/account/models/chart_template.py", line 146, in try_loading_for_current_company
wizard.execute()
File "/var/tmp/openupgrade/11.0/addons/account/models/chart_template.py", line 873, in execute
raise UserError(
('Could not install new chart of account as there are already accounting entries existing'))
odoo.exceptions.UserError: ('Could not install new chart of account as there are already accounting entries existing', '')
2018-08-13 08:15:09,390 3812 INFO odoo_migrated odoo.service.server: Initiating shutdown
2018-08-13 08:15:09,390 3812 INFO odoo_migrated odoo.service.server: Hit CTRL-C again or send a second signal to force the shutdown.

Seems account module not tolerate to create new char template if there are any entries in any account.account.

/account/models/chart_template.py:873

    existing_accounts = self.env['account.account'].search([('company_id', '=', self.company_id.id)])
    if existing_accounts:
        # we tolerate switching from accounting package (localization module) as long as there isn't yet any accounting
        # entries created for the company.
        if self.existing_accounting(self.company_id):
            raise UserError(_('Could not install new chart of account as there are already accounting entries existing'))

        # delete accounting properties
        prop_values = ['account.account,%s' % (account_id,) for account_id in existing_accounts.ids]
        existing_journals = self.env['account.journal'].search([('company_id', '=', self.company_id.id)])
        if existing_journals:
            prop_values.extend(['account.journal,%s' % (journal_id,) for journal_id in existing_journals.ids])
        accounting_props = self.env['ir.property'].search([('value_reference', 'in', prop_values)])
        if accounting_props:
            accounting_props.unlink()

        # delete account, journal, tax, fiscal position and reconciliation model
        models_to_delete = ['account.reconcile.model', 'account.fiscal.position', 'account.tax', 'account.move', 'account.journal']
        for model in models_to_delete:
            res = self.env[model].search([('company_id', '=', self.company_id.id)])
            if len(res):
                res.unlink()
        existing_accounts.unlink()

    company = self.company_id
    self.company_id.write({'currency_id': self.currency_id.id,
                           'accounts_code_digits': self.code_digits,
                           'anglo_saxon_accounting': self.use_anglo_saxon,
                           'bank_account_code_prefix': self.bank_account_code_prefix,
                           'cash_account_code_prefix': self.cash_account_code_prefix,
                           'chart_template_id': self.chart_template_id.id})

    #set the coa currency to active
    self.currency_id.write({'active': True})

    # When we install the CoA of first company, set the currency to price types and pricelists
    if company.id == 1:
        for reference in ['product.list_price', 'product.standard_price', 'product.list0']:
            try:
                tmp2 = self.env.ref(reference).write({'currency_id': self.currency_id.id})
            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)

    # Install all the templates objects and generate the real objects
    acc_template_ref, taxes_ref = self.chart_template_id._install_template(company, code_digits=self.code_digits, transfer_account_id=self.transfer_account_id)

    # write values of default taxes for product as super user and write in the config
    IrDefault = self.env['ir.default']
    if self.sale_tax_id and taxes_ref:
        IrDefault.sudo().set('product.template', "taxes_id", [taxes_ref[self.sale_tax_id.id]], company_id=company.id)
    if self.purchase_tax_id and taxes_ref:
        IrDefault.sudo().set('product.template', "supplier_taxes_id", [taxes_ref[self.purchase_tax_id.id]], company_id=company.id)

    # Create Bank journals
    self._create_bank_journals_from_o2m(company, acc_template_ref)

    # Create the current year earning account if it wasn't present in the CoA
    company.get_unaffected_earnings_account()
    return {}`
@pedrobaeza
Copy link
Member

That's not a fault in OpenUpgrade itself. You should have a problem in your previous BD. Check that your company has a chart of accounts assigned on chart_template_id field.

@miquelalzanillas
Copy link
Author

Solved! Exactly this was the problem.

I'm trying to update without include OCA accounting addons.

Thanks!

@JheffSan
Copy link

Hi miquel, I've also got the same error when I'm trying to update the web module in Odoo 11. May I know what kind of steps to fix this issue? Thanks.

@JheffSan
Copy link

Solved! Exactly this was the problem.

I'm trying to update without include OCA accounting addons.

Thanks!

Solved! Exactly this was the problem.

I'm trying to update without include OCA accounting addons.

Thanks!

Hi miquel, I've also got the same error when I'm trying to update the web module in Odoo 11. May I know what kind of steps to fix this issue? Thanks.

@miquelalzanillas
Copy link
Author

Hi @JheffSan !

Sorry for this late answer. Hope did you solve it!

The issue is related with an incosistency with chart_template_id of res.company. So I don't know how the web module can affect here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants