Skip to content

Commit

Permalink
[FIX] hr: fix l10n_mx install
Browse files Browse the repository at this point in the history
When installing l10n_mx, a error occurs

    Traceback (most recent call last):
    File "/data/build/odoo/odoo/service/server.py", line 1289, in preload_registries
        registry = Registry.new(dbname, update_module=update_module)
    File "<decorator-gen-15>", line 2, in new
    File "/data/build/odoo/odoo/tools/func.py", line 87, in locked
        return func(inst, *args, **kwargs)
    File "/data/build/odoo/odoo/modules/registry.py", line 91, in new
        odoo.modules.load_modules(registry, force_demo, status, update_module)
    File "/data/build/odoo/odoo/modules/loading.py", line 482, in load_modules
        processed_modules += load_marked_modules(cr, graph,
    File "/data/build/odoo/odoo/modules/loading.py", line 371, in load_marked_modules
        loaded, processed = load_module_graph(
    File "/data/build/odoo/odoo/modules/loading.py", line 206, in load_module_graph
        registry.setup_models(cr)
    File "/data/build/odoo/odoo/modules/registry.py", line 289, in setup_models
        model._setup_fields()
    File "/data/build/odoo/odoo/models.py", line 3294, in _setup_fields
        field.setup(self)
    File "/data/build/odoo/odoo/fields.py", line 512, in setup
        self.setup_nonrelated(model)
    File "/data/build/odoo/odoo/fields.py", line 4524, in setup_nonrelated
        m2m = model.pool._m2m
    AttributeError: 'Registry' object has no attribute '_m2m'

Since odoo#99438 hr is sintalled automatically
This means that when doing a -i l10n_mx, hr is installed too

hr will conditionnaly call a button_immediate_install in this case.

What's going on after that: It's a mess

button_immediate_install will create another registry
This registry will be present on some models that will ne used later
by the initial registry creating the missing _m2m case

For the record, here are some of the strange and key element during
the install

    2022-09-21 16:31:27,691 2579263 INFO test_mx odoo.modules.loading: loading 1 modules...
    2022-09-21 16:31:27,691 2579263 INFO test_mx odoo.modules.loading: Loading module base (1/1)
    ...
    2022-09-21 16:31:36,222 2579263 INFO test_mx odoo.modules.loading: Module base loaded in 8.53s, 8902 queries (+8902 other)
    2022-09-21 16:31:36,222 2579263 INFO test_mx odoo.modules.loading: 1 modules loaded in 8.53s, 8902 queries (+8902 extra)
    2022-09-21 16:31:36,240 2579263 INFO test_mx odoo.modules.loading: updating modules list
    2022-09-21 16:31:36,241 2579263 INFO test_mx odoo.addons.base.models.ir_module: ALLOW access to module.update_list on [] to user __system__ #1 via n/a
    2022-09-21 16:31:36,943 2579263 INFO test_mx odoo.addons.base.models.ir_module: ALLOW access to module.button_install on ['Mexico - Accounting'] to user __system__ #1 via n/a
    ...
    2022-09-21 16:31:49,775 2579263 INFO test_mx odoo.modules.loading: Loading module base_install_request (26/78)
    ...
    2022-09-21 16:31:50,043 2579263 INFO test_mx odoo.addons.base.models.ir_module: ALLOW access to module.button_install on ['Project', 'Email Marketing', 'Employees', 'Knowledge', 'Sign', 'Planning', 'Appointments', 'Surveys'] to user __system__ #1 via n/a
    2022-09-21 16:31:50,167 2579263 INFO test_mx odoo.modules.loading: Module base_install_request loaded in 0.39s, 228 queries (+228 other)
    ...
    2022-09-21 16:32:10,816 2579263 INFO test_mx odoo.modules.loading: Loading module l10n_mx (55/78)
    ...
    2022-09-21 16:32:17,618 2579263 INFO test_mx odoo.modules.loading: Module l10n_mx loaded in 6.80s, 4302 queries (+4332 other)
    ...
    2022-09-21 16:32:50,371 2579263 INFO test_mx odoo.modules.loading: Loading module hr (35/112)
    2022-09-21 16:32:57,594 2579263 INFO test_mx odoo.addons.base.models.ir_module: ALLOW access to module.button_immediate_install on ['Employees - Mexico'] to user __system__ #1 via n/a
    2022-09-21 16:32:57,594 2579263 INFO test_mx odoo.addons.base.models.ir_module: User #1 triggered module installation
    2022-09-21 16:32:57,595 2579263 INFO test_mx odoo.addons.base.models.ir_module: ALLOW access to module.button_install on ['Employees - Mexico'] to user __system__ #1 via n/a
    ...
    2022-09-21 16:32:58,558 2579263 ERROR test_mx odoo.modules.registry: Creating Registry <odoo.modules.registry.Registry object at 0x7f02cc0e8130>
    Stack (most recent call last):
    File "/home/xdo/osrc/master/odoo/odoo-bin", line 8, in <module>
        odoo.cli.main()
    File "/home/xdo/osrc/master/odoo/odoo/cli/command.py", line 56, in main
        o.run(args)
    File "/home/xdo/osrc/master/odoo/odoo/cli/server.py", line 179, in run
        main(args)
    File "/home/xdo/osrc/master/odoo/odoo/cli/server.py", line 173, in main
        rc = odoo.service.server.start(preload=preload, stop=stop)
    File "/home/xdo/osrc/master/odoo/odoo/service/server.py", line 1391, in start
        rc = server.run(preload, stop)
    File "/home/xdo/osrc/master/odoo/odoo/service/server.py", line 570, in run
        rc = preload_registries(preload)
    File "/home/xdo/osrc/master/odoo/odoo/service/server.py", line 1289, in preload_registries
        registry = Registry.new(dbname, update_module=update_module)
    File "<decorator-gen-15>", 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 91, in new
        odoo.modules.load_modules(registry, force_demo, status, update_module)
    File "/home/xdo/osrc/master/odoo/odoo/modules/loading.py", line 482, in load_modules
        processed_modules += load_marked_modules(cr, graph,
    File "/home/xdo/osrc/master/odoo/odoo/modules/loading.py", line 371, in load_marked_modules
        loaded, processed = load_module_graph(
    File "/home/xdo/osrc/master/odoo/odoo/modules/loading.py", line 248, in load_module_graph
        getattr(py_module, post_init)(cr, registry)
    File "/home/xdo/osrc/master/odoo/addons/hr/__init__.py", line 19, in _install_hr_localization
        l10n_mx.button_immediate_install()
    File "<decorator-gen-74>", line 2, in button_immediate_install
    File "/home/xdo/osrc/master/odoo/odoo/addons/base/models/ir_module.py", line 75, in check_and_log
        return method(self, *args, **kwargs)
    File "/home/xdo/osrc/master/odoo/odoo/addons/base/models/ir_module.py", line 486, in button_immediate_install
        return self._button_immediate_function(type(self).button_install)
    File "/home/xdo/osrc/master/odoo/odoo/addons/base/models/ir_module.py", line 607, in _button_immediate_function
        registry = modules.registry.Registry.new(self._cr.dbname, update_module=True)
    File "<decorator-gen-15>", 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 79, in new
        registry.init(db_name)
    File "/home/xdo/osrc/master/odoo/odoo/modules/registry.py", line 115, in init
        _logger.error(self, stack_info=True)
    2022-09-21 16:32:58,580 2579263 INFO test_mx odoo.modules.loading: loading 1 modules...
    2022-09-21 16:32:58,581 2579263 INFO test_mx odoo.modules.loading: Loading module base (1/1)
    ...
    2022-09-21 16:33:35,294 2579263 INFO test_mx odoo.modules.loading: Loading module base_install_request (30/85)
    ...
    2022-09-21 16:33:35,745 2579263 INFO test_mx odoo.modules.loading: Module base_install_request loaded in 0.45s, 131 queries (+131 other)
    ...
    2022-09-21 16:34:05,789 2579263 INFO test_mx odoo.modules.loading: Loading module l10n_mx (62/85)
    ...
    2022-09-21 16:34:28,497 2579263 INFO test_mx odoo.modules.loading: Loading module hr (35/113)
    ...
    2022-09-21 16:34:32,067 2579263 INFO test_mx odoo.modules.loading: Module hr loaded in 3.57s, 4092 queries (+4092 other)
    2022-09-21 16:34:32,067 2579263 INFO test_mx odoo.modules.loading: Loading module link_tracker (37/113)
    ...
    2022-09-21 16:34:32,690 2579263 INFO test_mx odoo.modules.loading: Module link_tracker loaded in 0.62s, 267 queries (+267 other)
    ...
    2022-09-21 16:35:04,063 2579263 INFO test_mx odoo.modules.loading: Modules loaded.
    2022-09-21 16:35:04,068 2579263 INFO test_mx odoo.modules.registry: Registry loaded in 125.514s
    2022-09-21 16:35:04,068 2579263 INFO test_mx odoo.addons.base.models.ir_module: getting next ir.actions.todo()
    2022-09-21 16:35:04,071 2579263 INFO test_mx odoo.addons.base.models.ir_module: next action is "Open Menu"
    2022-09-21 16:35:04,094 2579263 INFO test_mx odoo.modules.loading: Module hr loaded in 133.72s, 4344 queries (+81420 other)
    ...
    2022-09-21 16:35:04,094 2579263 INFO test_mx odoo.modules.loading: Loading module link_tracker (37/112)
    2022-09-21 16:35:04,163 2579263 ERROR test_mx odoo.modules.registry:
    setuping model: ir.model.fields()
    registry on model: <odoo.modules.registry.Registry object at 0x7f02cc0e8130>
    registry calling setup_models: <odoo.modules.registry.Registry object at 0x7f02e92399d0>

    2022-09-21 16:35:04,164 2579263 WARNING test_mx odoo.modules.loading: Transient module states were reset
    2022-09-21 16:35:04,165 2579263 ERROR test_mx odoo.modules.registry: Failed to load registry
    2022-09-21 16:35:04,165 2579263 CRITICAL test_mx odoo.service.server: Failed to initialize database `test_mx`.
    Traceback (most recent call last):
    File "/home/xdo/osrc/master/odoo/odoo/service/server.py", line 1289, in preload_registries
        registry = Registry.new(dbname, update_module=update_module)
    File "<decorator-gen-15>", 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 91, in new
        odoo.modules.load_modules(registry, force_demo, status, update_module)
    File "/home/xdo/osrc/master/odoo/odoo/modules/loading.py", line 482, in load_modules
        processed_modules += load_marked_modules(cr, graph,
    File "/home/xdo/osrc/master/odoo/odoo/modules/loading.py", line 371, in load_marked_modules
        loaded, processed = load_module_graph(
    File "/home/xdo/osrc/master/odoo/odoo/modules/loading.py", line 206, in load_module_graph
        registry.setup_models(cr)
    File "/home/xdo/osrc/master/odoo/odoo/modules/registry.py", line 293, in setup_models
        model._setup_fields()
    File "/home/xdo/osrc/master/odoo/odoo/models.py", line 3294, in _setup_fields
        field.setup(self)
    File "/home/xdo/osrc/master/odoo/odoo/fields.py", line 512, in setup
        self.setup_nonrelated(model)
    File "/home/xdo/osrc/master/odoo/odoo/fields.py", line 4524, in setup_nonrelated
        m2m = model.pool._m2m
    AttributeError: 'Registry' object has no attribute '_m2m'

Naive fix here: use button_install instead of button_immediate_install
(not even sure this is 100% correct)

All calls to button_immediate_install should be fixed maybe to avoid
a registryloadingception

closes odoo#100909

X-original-commit: 919c1f3
Signed-off-by: Yannick Tivisse (yti) <[email protected]>
Signed-off-by: Xavier Dollé (xdo) <[email protected]>
  • Loading branch information
Xavier-Do committed Sep 23, 2022
1 parent 569a7ad commit a99c73d
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion addons/hr/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@ def _install_hr_localization(cr, registry):
('state', 'not in', ['installed', 'to install', 'to upgrade']),
])
if l10n_mx:
l10n_mx.button_immediate_install()
l10n_mx.button_install()

0 comments on commit a99c73d

Please sign in to comment.