コンテンツへスキップ
メニュー
この質問にフラグが付けられました
2 返信
8739 ビュー

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. 


アバター
破棄
最善の回答

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.

アバター
破棄
著作者

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.

著作者 最善の回答

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.

アバター
破棄
関連投稿 返信 ビュー 活動
4
5月 21
28767
0
7月 20
2907
1
6月 23
2365
3
2月 22
10991
1
5月 21
4763