Overslaan naar inhoud
Menu
Je moet geregistreerd zijn om te kunnen communiceren met de community.
Deze vraag is gerapporteerd
2 Antwoorden
8791 Weergaven

There is an option in the menifest file to call method during module installation. We can mention pre_init and post_init. 

I would like to call one method while upgrading the module as similar to pre_init. because after module gets installed pre_init will not be called. 

Any suggestion for this ?

Why I need this ... 

I have a stored procedure to generate report data quickly which uses postgresql stored procedure, now when there is a slight change in the procedure I would like to update it thourh the module upgrade process. 


There should be some option available to call method during module upgrade as like pre_init and post_init. 


Avatar
Annuleer
Beste antwoord

You can call any method during module update by adding function tag in the xml file.

# Add following code in XML file
<function model="sale.order" name="action_custom_method"/>

@api.model
def action_custom_method(self):
# Your code goes here...
return True

This way method will be called after you upgrade the module.

Avatar
Annuleer
Auteur

Yes, it make sense, I will try it and let you know. But isn't there any option to call method during update as like pre_init? I am wondering, it should be there.

AFAIK I have never seen such thing for module update. Still, I am not 100% sure.

Auteur Beste antwoord

Finally, I got the solution.


We created one .sql file and into that file we added all our stored procedures and other database objects.


We added that sql file in the __manifest__.py


'data': [            
            'db_function/get_product_sales_history_data.sql',
            'db_function/update_product_sales_history.sql',
        ],

It will execute these sql files at the time of module installation as well as module upgrade time.

Avatar
Annuleer
Gerelateerde posts Antwoorden Weergaven Activiteit
4
mei 21
28841
0
jul. 20
2941
1
jun. 23
2397
3
feb. 22
11038
1
mei 21
4802