콘텐츠로 건너뛰기
메뉴
커뮤니티에 참여하려면 회원 가입을 하시기 바랍니다.
신고된 질문입니다
1 회신
2522 화면

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. 

아바타
취소
베스트 답변

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

아바타
취소
작성자

Thank you, it works!

관련 게시물 답글 화면 활동
1
3월 24
1553
2
7월 20
4335
1
1월 20
2870
1
12월 19
3126
0
2월 16
4362