Skip to Content
Menu
This question has been flagged
2 Replies
2911 Views

So I've made this function  It works great when the type of view it's tree but kanban is showing me this error

TypeError: Cannot read property 'context' of undefined


def fields_view_get(self, view_id=None, view_type='kanban', context=None, toolbar=False, submenu=False):
self.env['ot.general'].search([]).unlink()
sql ="SELECT DISTINCT(count(ot_model.status)) as cant, ot_status.name, ot_status.color FROM ot_model join ot_status on ot_model.status = ot_status.id group by ot_model.status, ot_status.name, ot_status.color"
self.env.cr.execute(sql)
ot = self.env.cr.fetchall()
ot = json.loads(json.dumps(ot))
vals = []
for elem in range(len(ot)):
vals.append({})
for subelem in range(len(ot[elem])):
if subelem == 0:
vals[elem]['cant'] = ot[elem][subelem]
if subelem == 1:
vals[elem]['name'] = ot[elem][subelem]
if subelem == 2:
vals[elem]['color'] = ot[elem][subelem]
print(vals)
self.env['ot.general'].create(vals)
return super(OtStatusGeneral, self).fields_view_get(view_id=view_id, view_type='kanban', toolbar=toolbar, submenu=submenu)


Avatar
Discard
Best Answer

Hi,  Wildhen


You have defined wrong parameters inside the method that's why you are getting this issue.

Kindly follow below parameter in order to fix this issue.

def fields_view_get(self, view_id=None, view_type='form', toolbar=False, submenu=False):

Thanks,
Ashish Singh(Team Lead)
Webkul Software Private Limited

Avatar
Discard
Author Best Answer
fields_view_get(view_id=view_id, view_type=view_type)
Avatar
Discard