Bỏ qua để đến Nội dung
Menu
Câu hỏi này đã bị gắn cờ
1 Trả lời
2469 Lượt xem

I have a self.env['my.model'].search([]) in a function called by a field default. This field is in a model that inherits from res.partner. It works well if the module is installed. But fails when I install the module in a new database. The errors is that it can't find the relation my_model in the database.

I supose that during installation, the new my_model model exists only for odoo, but is not accessible in the postgresql database. The search function calls a SQL query and it fails. Res.partner exists already, and it try to compute all the default fields and calls the SQL query before it finish the installation. 

There is a way to ask odoo if the model exists before doing a search([])?

Thanks in advance. 

Ảnh đại diện
Huỷ bỏ
Câu trả lời hay nhất

change python file loading sequence (by __init__.py import sequence) 
 first load the py file which defines your model(my.model) and then it load your inherited res.partner model with default

Ảnh đại diện
Huỷ bỏ
Tác giả

Thank you, it works!

Bài viết liên quan Trả lời Lượt xem Hoạt động
1
thg 3 24
1413
2
thg 7 20
4180
1
thg 1 20
2690
1
thg 12 19
3126
0
thg 2 16
4221