Xavier ALT 739aa00a49 [FIX] point_of_sale: fix loading of chart of account with default pos.config
With `generic_coa` now installed by default, the default pos.config are
automatically assigned a sale and an invoice journal, and trying to install
afterward a country specific chart template result in the following error:

2023-04-03 16:29:27,642 9344 ERROR _testdb-162820-testdb-162820-point-of-sale odoo.sql_db: bad query: DELETE FROM "account_journal" WHERE id IN (1, 2, 3, 8, 4, 6, 9, 7, 5, 10)
ERROR: update or delete on table "account_journal" violates foreign key constraint "pos_config_journal_id_fkey" on table "pos_config"
DETAIL:  Key (id)=(10) is still referenced from table "pos_config".

Traceback (most recent call last):
  ...
  File "/home/odoo/src/odoo/saas-16.2/odoo/modules/loading.py", line 481, in load_modules
    processed_modules += load_marked_modules(env, graph,
  File "/home/odoo/src/odoo/saas-16.2/odoo/modules/loading.py", line 365, in load_marked_modules
    loaded, processed = load_module_graph(
  File "/home/odoo/src/odoo/saas-16.2/odoo/modules/loading.py", line 297, in load_module_graph
    module.write({'state': 'installed', 'latest_version': ver})
  File "/home/odoo/src/odoo/saas-16.2/addons/account/models/ir_module.py", line 67, in write
    self.env['account.chart.template'].try_loading(
  File "/home/odoo/src/odoo/saas-16.2/addons/account/models/chart_template.py", line 141, in try_loading
    return self._load(template_code, company, install_demo)
  File "/home/odoo/src/odoo/saas-16.2/addons/point_of_sale/models/chart_template.py", line 16, in _load
    result = super()._load(template_code, company, install_demo)
  File "/home/odoo/src/odoo/saas-16.2/addons/account/models/chart_template.py", line 176, in _load
    self.env[model].search([('company_id', '=', company.id)]).with_context({MODULE_UNINSTALL_FLAG: True}).unlink()
  File "/home/odoo/src/odoo/saas-16.2/addons/account/models/account_journal.py", line 524, in unlink
    ret = super(AccountJournal, self).unlink()
  File "/home/odoo/src/odoo/saas-16.2/addons/mail/models/mail_thread.py", line 326, in unlink
    res = super(MailThread, self).unlink()
  File "/home/odoo/src/odoo/saas-16.2/addons/mail/models/mail_activity_mixin.py", line 246, in unlink
    result = super(MailActivityMixin, self).unlink()
  File "/home/odoo/src/odoo/saas-16.2/odoo/models.py", line 3635, in unlink
    cr.execute(query, (sub_ids,))
  File "/home/odoo/src/odoo/saas-16.2/odoo/sql_db.py", line 311, in execute
    res = self._obj.execute(query, params)
psycopg2.errors.ForeignKeyViolation: update or delete on table "account_journal" violates foreign key constraint "pos_config_journal_id_fkey" on table "pos_config"
DETAIL:  Key (id)=(10) is still referenced from table "pos_config".

This commit also reset the journals on the existing pos.config so that
`post_install_pos_localisation()` assign the right ones once the new
chart template is loaded.

We also only reset payment methods and journals in case we load a new
chart of accounts (this fix the "reload" of the CoA when PoS is
installed)

closes odoo/odoo#117651

X-original-commit: 7a91c57f6bb47e40f0486ca06f0e1916b98db1f4
Signed-off-by: Joseph Caburnay (jcb) <jcb@odoo.com>
Signed-off-by: Xavier Alt (xal) <xal@odoo.com>
2023-04-04 17:03:32 +02:00
2023-04-04 13:35:45 +02:00
…
…
…
2023-01-03 13:16:02 +01:00

Build Status Tech Doc Help Nightly Builds

Odoo

Odoo is a suite of web based open source business apps.

The main Odoo Apps include an Open Source CRM, Website Builder, eCommerce, Warehouse Management, Project Management, Billing & Accounting, Point of Sale, Human Resources, Marketing, Manufacturing, ...

Odoo Apps can be used as stand-alone applications, but they also integrate seamlessly so you get a full-featured Open Source ERP when you install several Apps.

Getting started with Odoo

For a standard installation please follow the Setup instructions from the documentation.

To learn the software, we recommend the Odoo eLearning, or Scale-up, the business game. Developers can start with the developer tutorials

S
Description
No description provided
Readme LGPL-3.0
3.4 GiB
Languages
Python 49.6%
JavaScript 47.8%
SCSS 2%
CSS 0.3%
HTML 0.2%