在我的课堂上有一个两个选择的现场出勤和休假类型,当出勤出现时,当我的出勤率是绝对的,假期类型选择字段是必需的,并且我选择作为病假,我选择休假类型当我编辑同一记录时我保存记录,并且我正在将出勤标记为现在,请假类型字段值应该为假。我只给出了假的字段,但是记录保存在数据库中...任何人都可以帮助这个
这是onchange功能
@api.onchange('attendance', 'employee_id', 'attendance_date')
def onchange_attendance(self):
if self.attendance:
if self.attendance == 'present':
time_in = time_out = False
self.present = True
self.absent = False
self.half_day = False
self.late = False
self.comp_off = False
self.leave_type = False
self.holiday = False
self.weekly_off = False
self.compensation_date = False
if self.attendance == 'absent':
self.present = False
self.absent = True
self.half_day = False
self.late = False
self.comp_off = False
self.holiday = False
self.weekly_off = False
self.compensation_date = False
if self.attendance == 'half_day':
self.present = False
self.absent = False
self.half_day = True
self.late = False
self.comp_off = False
self.holiday = False
self.weekly_off = False
self.compensation_date = False
if self.attendance == 'comp_off':
self.present = False
self.absent = False
self.half_day = False
self.late = False
self.comp_off = True
self.leave_type = False
self.holiday = False
self.weekly_off = False
if self.attendance == 'holiday':
self.present = False
self.absent = False
self.half_day = False
self.late = False
self.comp_off = False
self.leave_type = False
self.holiday = True
self.weekly_off = False
self.compensation_date = False
if self.attendance == 'weekly_off':
self.present = False
self.absent = False
self.half_day = False
self.late = False
self.comp_off = False
self.leave_type = False
self.holiday = False
self.weekly_off = True
self.compensation_date = False
答案 0 :(得分:0)
我总结了你的观点。
如果要更新此字段值,则必须在write方法中执行此操作。
@api.multi
def write(self, vals):
res = super(*yourmodel*, self).write(vals)
if vals.get('attendance') and vals.get('attendance') == 'present':
self.leave_type = False
return res
我希望它会有所帮助。