计算字段语法错误,修改如下: for record in self: year_diff = int(record.x_hr_month[0:4]) - record.x_startdate_efficientcy.year month_diff = int(record.x_hr_month[4:]) - record.x_startdate_efficientcy.month x_month = year_diff*12 + month_diff + 1 if record.x_employee_id.hire_date.day<15: if record.x_employeegrade == 'G1': record['x_person_efficiency'] = 0 elif record.x_employeegrade == 'G5': record['x_person_efficiency'] = 1 elif record.x_employeegrade == 'G2': if x_month<1: record['x_person_efficiency'] = 0 elif 1<=x_month<=3: record['x_person_efficiency'] = 0.25 elif 4<=x_month<=6: record['x_person_efficiency'] = 0.5 elif x_month>=7: record['x_person_efficiency'] = 1 elif record.x_employeegrade == 'G3': if x_month<1: record['x_person_efficiency'] = 0 elif 1<=x_month<=3: record['x_person_efficiency'] = 0.5 elif 4<=x_month: record['x_person_efficiency'] = 1 elif record.x_employeegrade == 'G4': if x_month<1: record['x_person_efficiency'] = 0 elif 1==x_month: record['x_person_efficiency'] = 0.5 elif 2<=x_month: record['x_person_efficiency'] = 1 else: if record.x_employeegrade == 'G1': record['x_person_efficiency'] = 0 elif record.x_employeegrade == 'G5': record['x_person_efficiency'] = 1 elif record.x_employeegrade == 'G2': if x_month<1: record['x_person_efficiency'] = 0 elif 1<=x_month<=4: record['x_person_efficiency'] = 0.25 elif 5<=x_month<=7: record['x_person_efficiency'] = 0.5 elif x_month>=8: record['x_person_efficiency'] = 1 elif record.x_employeegrade == 'G3': if x_month<1: record['x_person_efficiency'] = 0 elif 1<=x_month<=4: record['x_person_efficiency'] = 0.5 elif 4<=x_month: record['x_person_efficiency'] = 1 elif record.x_employeegrade == 'G4': if x_month<1: record['x_person_efficiency'] = 0 elif 1<=x_month<=2: record['x_person_efficiency'] = 0.5 elif 3<=x_month: record['x_person_efficiency'] = 1
导入数据报错
SLAL2-1605 Pro 【夏尔天逸】涉及计算字段的自定义模型