def write(self,vals):
for record in self:
emp_id = record.employee_name
user = self.env['res.users'].search([("email",'=',record.mail)])
if vals.get('unit_icon'):
if vals.get('unit_name'):
members = self.env['team.works'].search([('unit_name.id','=',vals.get('unit_name'))])
else:
members = self.env['team.works'].search([('unit_name.id','=',record.unit_name['id'])])
#print("---------------------------1")
#print(type(vals.get('unit_icon')))
b = bytes(vals.get('unit_icon'), 'utf-8') #This line the give the error
#print(b)
#print("---------------------------2")
for i in members:
#print("---------------------------3")
#print(type(i['unit_icon']))
#print(i['unit_icon'])
i['unit_icon'] = b
#print("---------------------------4")
Hi everyone. I am working on the in odoo project.If the logo is changed, I want to updated logo of other members but there is a problem.Changed logo class is a string.Updated logo other members logo class is bytes other member logo.I am trying to string to bytes to achive this
b = bytes(vals.get('unit_icon'), 'utf-8')
After changed class but it give me the error "TypeError: encoding without a string argument". What is the problem of the code ?
if vals.get('unit_icon') is string then Pythonic way is:
b = vals.get('unit_icon').encode() # encode defaults to 'utf-8'