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

I have a multi-level organisational structure (Branches, Regions, Districts,  Formations) and I'd like to filter the available organisations based on its parent.


For each of the orgs with a parent (regions, districts, formations), their source model includes the relationship to the parent, i.e. 

Regions - includes a Branches field.

Districts - includes a Regions field.

Formations - includes a Districts fields.


So what I'd like to do is filter the list of available Regions based on the selected Branch. filter the list of available Districts based on the selected Region and filter the list of available Formations based on the selected District.


I'm using Odoo cloud and the studio portal, so I can't use custom code. Id assume I need to use the domain option, but I just can't figure out the syntax.

아바타
취소
베스트 답변

You need to create function and add the result as the domain

the function should be similar like this

def _get_district_domain(self):
​region_id = self.region.id
​return [('parent_id', '=', region_id)]

districts = fields.Many2one(... domain=_get_district_domain)

Keep in mind that you have to define the field after the method. User same pattern for formation field

아바타
취소