Xavier-Do ae000f07e1 [FIX] loading: check ir_module existence
When instantiating a new registry, this piece of code is called

    try:
        odoo.modules.load_modules(registry, force_demo, status, update_module)
    except Exception:
        odoo.modules.reset_modules_state(db_name)
        raise

For a new database, load_modules will create the table ir_module_module
in the same transaction as everything else. This means that if any error
occurs, the transaction is rollbacked and the table ir_module may not
exist.

`reset_modules_state` will try to access ir_module_module table leading
to another error and an unecessary and confusing error log.

2023-04-26 12:05:34,823 616958 ERROR ? odoo.sql_db: bad query: UPDATE ir_module_module SET state='installed' WHERE state IN ('to remove', 'to upgrade')
ERROR: relation "ir_module_module" does not exist
LINE 1: UPDATE ir_module_module SET state='installed' WHERE state IN...
               ^

    2023-04-26 12:05:34,823 616958 ERROR ? odoo.modules.registry: Failed to load registry
    2023-04-26 12:05:34,824 616958 CRITICAL ? odoo.service.server: Failed to initialize database `test-base`.
    Traceback (most recent call last):
    File "/home/xdo/osrc/master/odoo/odoo/modules/registry.py", line 90, in new
        odoo.modules.load_modules(registry, force_demo, status, update_module)
    File "/home/xdo/osrc/master/odoo/odoo/modules/loading.py", line 386, in load_modules
        raise Exception('An error')
    Exception: An error

    During handling of the above exception, another exception occurred:

    Traceback (most recent call last):
    File "/home/xdo/osrc/master/odoo/odoo/service/server.py", line 1302, in preload_registries
        registry = Registry.new(dbname, update_module=update_module)
    File "<decorator-gen-14>", line 2, in new
    File "/home/xdo/osrc/master/odoo/odoo/tools/func.py", line 87, in locked
        return func(inst, *args, **kwargs)
    File "/home/xdo/osrc/master/odoo/odoo/modules/registry.py", line 92, in new
        odoo.modules.reset_modules_state(db_name)
    File "/home/xdo/osrc/master/odoo/odoo/modules/loading.py", line 622, in reset_modules_state
        cr.execute(
    File "/home/xdo/osrc/master/odoo/odoo/sql_db.py", line 311, in execute
        res = self._obj.execute(query, params)
    psycopg2.errors.UndefinedTable: relation "ir_module_module" does not exist
    LINE 1: UPDATE ir_module_module SET state='installed' WHERE state IN...

With this commit, we check the ir_module_module table existance avoiding
an exception and revealing the minimal traceback.

2023-04-26 12:11:21,218 617810 INFO ? odoo.modules.loading: skipping reset_modules_state, ir_module_module table does not exists
2023-04-26 12:11:21,218 617810 ERROR ? odoo.modules.registry: Failed to load registry
2023-04-26 12:11:21,218 617810 CRITICAL ? odoo.service.server: Failed to initialize database `test-base`.
Traceback (most recent call last):
  File "/home/xdo/osrc/master/odoo/odoo/service/server.py", line 1302, in preload_registries
    registry = Registry.new(dbname, update_module=update_module)
  File "<decorator-gen-14>", line 2, in new
  File "/home/xdo/osrc/master/odoo/odoo/tools/func.py", line 87, in locked
    return func(inst, *args, **kwargs)
  File "/home/xdo/osrc/master/odoo/odoo/modules/registry.py", line 90, in new
    odoo.modules.load_modules(registry, force_demo, status, update_module)
  File "/home/xdo/osrc/master/odoo/odoo/modules/loading.py", line 386, in load_modules
    raise Exception('An error')

closes odoo/odoo#119820

Exception: An error
Signed-off-by: Raphael Collet <rco@odoo.com>
2023-04-27 06:10:18 +02:00
2023-04-26 17:06:36 +02: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%