Skip to Content
Menu
Musisz się zarejestrować, aby móc wchodzić w interakcje z tą społecznością.
To pytanie dostało ostrzeżenie
1 Odpowiedz
2537 Widoki

Assume both modules "A" and "B" overrode the create function of the same model. now module "C" depends on both of these modules:

"depends": ['A', 'B'],


Now when I call super in the create function of the same model in "C" module, which one will be called? the override in "A" or in "B"?

Awatar
Odrzuć
Najlepsza odpowiedź

Hi,

In Odoo, when multiple modules override the same function of a model, the order in which the overridden methods are called is determined by the sequence in which the modules are loaded. By default, Odoo will load modules in the order they are declared in the depends list of the manifest file (usually the __manifest__.py file).

So, in your scenario, if module "C" depends on both modules "A" and "B" as follows:
'depends': ['A', 'B'],

The method from the module listed first in the depends list, in this case, "A," will be called first when you use super() in the create function of module "C." After that, the method from module "B" will be called if it also uses super().

Keep in mind that Odoo's module loading mechanism can be influenced by the installation order and any dependencies that may be defined within the modules. If you need to control the order more explicitly, you can use the sequence attribute in the module manifest to specify the load sequence for each module.


Hope it helps

Awatar
Odrzuć
Autor

Changin the order of the modules in the dependency list doesn't change functionality. But the sequence attribute you mentioned was the exact thing I needed. thanks

Powiązane posty Odpowiedzi Widoki Czynność
1
wrz 21
10594
5
mar 20
11577
1
lip 22
4733
0
kwi 22
4256
0
mar 15
6264