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

i have this function to make 'holiday_status_id' field dynamic domain
it works fine but only with CREATE button
how can i make it available all time


@api.model
@api.onchange('employee_id', 'type', 'state','holiday_status_id')
def change_leave_type(self):
for holiday_type in self:
if holiday_type.type == 'add':
if holiday_type.state in ['draft', 'confirm', 'validate', 'validate1']:
if holiday_type.type == 'add' and holiday_type.env.uid == holiday_type.user_id.id and not holiday_type.env.user.has_group(
'hr_holidays.group_hr_holidays_user'):
allocate_type = holiday_type.env['hr.holidays.status'].search(
[('name', '=', 'Compensatory Days')]).id
return {'domain': {'holiday_status_id': [('id', '=', allocate_type)]}}
elif holiday_type.type == 'add' and holiday_type.env.user.has_group(
'hr_holidays.group_hr_holidays_user') and not holiday_type.env.user.has_group(
'hr_holidays.group_hr_holidays_manager'):
ids = []
allocation_types = holiday_type.env['hr.holidays.status'].search([])
for allocate in allocation_types:
if allocate.name != 'Unpaid':
ids.append(allocate.id)
return {'domain': {'holiday_status_id': [('id', '=', ids)]}}
아바타
취소
베스트 답변

Hello,

Try to remove @api.model

아바타
취소
작성자

OK Sam ... i removed it ... but still work only with 'CREATE' Button if i click on edit it doesn't work

thanks

Why don't you just add the domain in XML? Something like:

<field holiday_status_id domain="[('name', '!=', 'Unpaid')]"/>

작성자

it doesn't work because it will affect two actions not only one 'open_allocation_holidays' action for 'Allocation' and 'ask_new_holidays action' action for 'Leave Request'

i need to add this function to only allocation action

thanks sam

관련 게시물 답글 화면 활동
0
1월 20
3525
1
12월 19
4390
1
5월 24
3266
3
6월 23
16300
1
3월 22
13820