python - Couldnt see the result of computed field as a normal user in ODOO V8 -
i have problem, have 2 float computed fields. result , value seen if logged in adminstrator, couldnt seen if logged in normal user. ive set security in modul here field :
class overtime_details(models.model): _name='overtime.overtime_details' ovrtm = fields.float(compute=attd_check, string='overtime hour(s)') ttalmtp = fields.float(compute=overtype_count, string='total multiplier')
and here picture when logged in normal user :
then here picture when logged in administrator :
and here security permission csv :
id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink overtime_formsec,overtime_formsec,model_overtime_overtime,,1,1,1,1 overtime_employee_list,overtime_employee_list,model_overtime_overtime_details,,1,1,1,1 overtime_type_list,overtime_type_list,model_overtime_type_overtime,,1,1,1,1 overtime_type_hours,overtime_type_hours,model_overtime_hour_overtime,,1,1,1,1
and here attd_check function :
@api.model def attd_check(self): #import pdb;pdb.set_trace() attds in self: if attds.id: ov = 0.0 attd = self.env['hr.attendance'] paratime = (datetime.strptime(attds.overtime_id.start_date, "%y-%m-%d %h:%m:%s") - relativedelta(days=1, hours=7)).strftime("%y-%m-%d 23:59:59") signin = attd.search([('name','<=',attds.overtime_id.start_date), ('name','>',paratime), ('employee_id','=',attds.employee_id.id), ('action','=','sign_in')]) signout = attd.search([('name','>=',attds.overtime_id.end_date), ('employee_id','=',attds.employee_id.id), ('action','=','sign_out')]) signout2 = attd.search([('name','<',attds.overtime_id.end_date), ('name','>',attds.overtime_id.start_date), ('employee_id','=',attds.employee_id.id), ('action','=','sign_out')]) if signin: if signout: ov = attds.env['overtime.overtime'].calc_overtime(attds.overtime_id.start_date, attds.overtime_id.end_date) elif signout2: paramtole = datetime.strptime(signout2.name, "%y-%m-%d %h:%m:%s").strftime("%m:%s") tolerate = datetime.strptime("15:00", "%m:%s").strftime("%m:%s") tolerate2 = datetime.strptime(str(attds.overtime_id.tolerance), "%m.%s").strftime("%m:%s") if paramtole >= tolerate2 : ov = attds.env['vit_overtime.overtime'].calc_overtime(attds.overtime_id.start_date, signout2.name) + 1 elif paramtole < tolerate : ov = attds.env['overtime.overtime'].calc_overtime(attds.overtime_id.start_date, signout2.name) else : ov = attds.env['overtime.overtime'].calc_overtime(attds.overtime_id.start_date, signout2.name) else: ov = 0.0 else: ov = 0.0 attds.ovrtm = ov
overtype count function :
@api.model def overtype_count(self): #import pdb;pdb.set_trace() det in self: if det.id: check = self.env['overtime.hour_overtime'].search([('hour_id.code','=',det.overtime_id.overtimetype_id.code)]) if check: if det.overtime_id.state == 'done': ovt=0 counter = 1 hou in check: if det.ovrtm <= 0: det.ovrtm = ovt elif counter <= det.ovrtm: ttal = ovt + hou.calc ovt = ttal counter = counter + 1 else : det.ttalmtp = ovt else : det.ttalmtp = 0
what should resolve this, before :)
i have solved this, added sudo() before search or browse in function, example:
before:
signin = attd.search([('name','<=',attds.overtime_id.start_date), ('name','>',paratime), ('employee_id','=',attds.employee_id.id), ('action','=','sign_in')])
after adding sudo():
signin = attd.sudo().search([('name','<=',attds.overtime_id.start_date), ('name','>',paratime), ('employee_id','=',attds.employee_id.id), ('action','=','sign_in')])
Comments
Post a Comment