My module with my.custom.model depends on the base and mail modules.
However, when (for example) sale module will be installed, must create a predefined record in the my.custom.model.
Creating predefined record for sale in data/my_module_data.xml does not make sense (error if sale not exist).
How to do it? Any suggestions?
Cette question a été signalée
Why don't you create another module that depends on sale module and do the stuff you want to do.
If you don't want to create another module then inherit "ir.module.module" object in your module and override the "button_install" method, first call the super method and then create predefined records.
Thank you for the right suggestions. However, it only gives half of the solution. Works if my module is installed first. What to do when the sale module is installed earlier.
Hi Zbik,
If your module is always installed last you can move the data logic from the XML to the Python side? In this case you can create a post_init_hook which goes off when you install the module. In the hook you can then check which modules are (or are not) installed and then insert a set of data depending on this.
# manifest.py 'post_init_hook': 'post_init_hook',
# your_python_file.py
def post_init_hook(cr, registry):
env = api.Environment(cr, SUPERUSER_ID, {}) # do your checks and insertion here
If it is the other way around (or you don't know it for sure) you can also override the installation module of apps and do your extra logic there, just like Sudhir suggested. The combination of these both methods should cover all cases.
Regards,
Yenthe
Thank you Yenthe. You're right. Combination of both methods will be the solution that I need :)
Awesome, best of luck!
Vous appréciez la discussion ? Ne vous contentez pas de lire, rejoignez-nous !
Créez un compte dès aujourd'hui pour profiter de fonctionnalités exclusives et échanger avec notre formidable communauté !
S'inscrire| Publications associées | Réponses | Vues | Activité | |
|---|---|---|---|---|
|
Data for relations table
Résolu
|
|
1
avr. 24
|
3927 | |
|
|
1
août 22
|
4105 | ||
|
|
0
mai 17
|
9146 | ||
|
|
1
mars 15
|
5441 | ||
|
|
2
mars 15
|
5852 |