Skip to Content
Menu
This question has been flagged
3 Replies
2582 Views
File "/opt/odoo/odoo/models.py", line 4042, in _where_calc
    where_clause, where_params = e.to_sql()
  File "/opt/odoo/odoo/osv/expression.py", line 1290, in to_sql
    q, p = self.__leaf_to_sql(leaf)
  File "/opt/odoo/odoo/osv/expression.py", line 1157, in __leaf_to_sql
    "Invalid value %r in domain term %r" % (right, leaf)
AssertionError: Invalid value jntukstudent.course(2,) in domain term ('course', '=', jntukstudent.course(2,))

py file:
@api.multi
@api.onchange('course')
def onchange_class_info1(self):
'''Method to get student roll no'''
stud_list = []
stud_obj = self.env['jntuk.student']
for rec in self:
if rec.course:
stud_list = [{'roll_no': stu.name}
for stu in stud_obj.search([('course', '=',
rec.course),
])]
rec.student_id = stud_list
 

Avatar
Discard
Best Answer

Hello

You have to pass the integer value instead of object into the domain, so make the following change into your method. then try to execute your code.

    @api.multi
    @api.onchange('course')
    def onchange_class_info1(self):
        '''Method to get student roll no'''
        stud_list = []
        stud_obj = self.env['jntuk.student']
        for rec in self:
            if rec.course:
                stud_list = [{'roll_no': stu.name}
                             for stu in stud_obj.search([('course', '=',
                                                          rec.course.id),
                                                         ])]
            rec.student_id = stud_list
Avatar
Discard
Best Answer

Hello,

In domain you are passing browse object of  jntukstudent.course(2,)    instead of id, so you are getting that error

Avatar
Discard
Author Best Answer

Thank you sooo much mithul

Avatar
Discard