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

I have two modules.
Both inheriting sale module.
Both have same field demo in py and xml.
Both having same on_change method in it with same parameter.

Question is if both modules are installed which module on_change will trigger.

How Odoo/Openerp Modules will take preference?? By module name or Installation time or any other factor??

아바타
취소
베스트 답변

if you are asking for debug purposes.. probably the last installed will be triggered.. 
but that is bad practice and confusing code.. try to avoid it.. because if you install both modules you will probably get fields in your views shown twice wich is very bad... OE does not handle well if same field is shown twice on one view...
if you have two modules using(and needing)  the same attribute probably the best solution is to make third module which will contain that attribute (also methods and views for it) and the two original modules can depend on new one.. so you will avoid double adding fields..

아바타
취소
작성자

I can handle the twice field issue by fields_view_get using lxml properties. But i want to know the module preferences. And no, it wont get triggered on the basis of installation while debugging.

베스트 답변

It depends on your your type of inheritance for your custom modules.

If both modules use class inheritance ( _inherit = 'parent.model', _name = 'parent.model'), the both fields will be exactly the same.

if you use prototype inheritance ( _inherit = 'parent.model', _name = 'new.name'), the database will contain different tables for your new custom modules. This will result in no conflict, since the fields (although they have the same name) are part of different database tables.

EDIT:

I'm not sure, which on_change method will be used in your case. Maybe the last installed module will determine it. Maybe the sequence/order of the views will play a role.

You should think about your design and maybe try to change the inheritance.

Why not using one custom module instead of two?
Or let module A inherit from Sales and module B from module A?

 

Regards.

아바타
취소
작성자

Okay. I forgot to add this. I use class inheritance (_inherit = 'parent.model', _name = 'parent.model') on both modules. Module A, Module B.

관련 게시물 답글 화면 활동
3
7월 25
2226
3
5월 25
3855
2
6월 25
4323
0
6월 21
2485
1
8월 24
3642