我正在尝试使用Openerp 7.0编写一个新的Roster模块,并且在从一名员工取消名单并将该特定名单分配给另一名(替补)员工时遇到问题。 以下就是我做的......
我的时段定义类
class roster_time(osv.osv):
_name="roster.time"
_description = "To create roster time slot"
_columns={
'roster_id':fields.integer('Roster ID'),
'start_time': fields.char('Start Time',required=True),
'end_time':fields.char('End Time',required=True),
'rostertype':fields.many2one('roster.type','roster','Roster Time'),
'name':fields.char('Roster Time'),
}
roster_time()
名册定义类
class roster_type(osv.osv):
_name="roster.type"
_description = "To create roster type for each department"
_columns={
'name': fields.char('Roster type'),
'roster':fields.one2many('roster.time','rostertype','Time Slot'),
'allocation_id':fields.many2one('roster.allocation','Roster ID'),
'roster_time':fields.many2one('roster.time','Slot'),
'roster_end':fields.related('roster.time','roster_start',type='char',string='End Time'),
'allocation_start_day':fields.date('Start Date' ),
'allocation_end_day':fields.date('End Date'),
'department_id':fields.many2one('hr.department','Department',required=True),
}
roster_time()
名册分配类
class roster_allocation(osv.osv):
_name="roster.allocation"
_description ="Allocate rosters on employees"
_columns={
'emp_id':fields.many2one('hr.employee','Employee',required=True),
'department_id':fields.many2one('hr.department','Department',required=True),
#'roster':fields.many2one('roster.type','roster', 'Roster ID'),
'roster_linked_ids':fields.one2many('roster.type','allocation_id','Roster Linked Ids'),
'roster_type':fields.related('roster.type','department_id', type='char', string='Roster Type'),
'roster_time':fields.char('Take the related field roster_time.name'),
'monthly allocation':fields.char('Month') ,
'roster_rest_allocation':fields.one2many('roster.rest.days','roster_id','Rest Days'),
'roster_substitute':fields.one2many('roster.substitution','allocation_id','Substitution'),
}
roster_allocation()
名册取消课程
class roster_substitution(osv.osv):
_name="roster.substitution"
_description="Substituting employees "
_columns={
'allocation_id':fields.many2one('roster.allocation','Allocation'),
'employee':fields.many2one('hr.employee','Employee'),
'sub_employee':fields.many2one('hr.employee','Employee'),
'time_slot':fields.many2one('roster.time','Roster'),
'roster_day':fields.date('Day'),
'reason':fields.text('Reason'),
'department_id':fields.many2one('hr.department','Department'),
}
roster_substitution()
"我已经删除了该场合的所有验证和其他计算。"
我的问题是 1)。在名单取消类中,一旦我选择部门,我需要在特定字段中自动加载名册时间段,以及一旦我从中选择一个时间段和日期,我需要显示已分配的员工在那个只读字段
2)。一旦我选择了替代员工,我需要在该替代员工中添加取消请求员工的时段的时段,并且在原始员工中我需要以不同的颜色显示它。
请帮我解决这个问题,即使我尝试了第一个问题的改变功能,我也不知道做一个最重要的问题。
请帮我解决这个问题。
这是我尝试过的功能,但我知道这是错误的
def allocation_substitute(self,cr,uid,ids,roster_day,context=None):
sub_day=vals.get(roster_day)
sub_time_slot=vals.get(time_slot)
allocation_obj=self.pool.get('roster.allocation')
original_employee_id = allocation_obj.browse(cr,uid, values['emp_id']).id
original_employee_roster=allocation_obj.browse(cr,uid, original_employee_id).roster_type
values={'emp_id':'employee',
'department_id':'department_id',
}
allocation_id=allocation_obj.create(cr, uid, value, context=context)