我目前正在使用兩個類,現在我處於一個混亂狀態。請幫我解決這個Openerp如何更新兩個類中的字段值
我需要做的就是曾經在「roster_allocation」級要取消他/她被分配花名冊僱員,然後爲目的,你必須要經過「roster_substitution」級,這使記錄原始分配和替代分配以及日期和時間。一旦你通過該表輸入記錄,我想用**「roster_substitute」**表中的substitute_employee_id更新現有的employee_id來更新該特定的「roster_allocation」表記錄。
這些都是我的兩個班
名冊配置類別
class roster_allocation(osv.osv):
_name="roster.allocation"
_description ="Allocate rosters on employees"
_columns={
'emp_id':fields.many2one('hr.employee','Employee'),
'department_id':fields.many2one('hr.department','Department'),
'roster_allocation_allocation':fields.one2many('roster.days.allocation','roster_allocation_connection','Days connection'),
'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_days_allocation(osv.osv):
_name="roster.days.allocation"
_description = "To allocate days in to the already defined time slots"
def get_domain_useer_id(self,cr,uid,ids,roster_type_list,context=None):
mach=[]
filter = self.pool.get('roster.type').search(cr,uid,[('id','=',roster_type_list)])
return {'domain':{'roster_time_list':[('rostertype','=',filter)]}}
_columns={
'name':fields.char('Days_Allocation'),
'allocation_start_day':fields.date('Start Date',required=True),
'allocation_end_day':fields.date('End Date',required=True),
'type_connection':fields.one2many('roster.type','date_allocation_connection','Roster Type'),
'roster_type_list':fields.many2one('roster.type','Rosters'),
'roster_time_list':fields.many2one('roster.time','Time Slot'),
'roster_allocation_connection':fields.many2one('roster.allocation','Allocation Connection')
}
roster_days_allocation()
名冊替換類(wh ICH保持最初分配員工和替代員工)的記錄
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'),
}
def onchange_date(self, cr, uid, ids, roster_date):
result = {'value': {'type': False}}
if type_id:
type = self.pool.get('roster.time').browse(cr, uid, roster_date)
result['value'] = {'time_slot': type.name.id}
return result
roster_substitution()
請幫我解決這個