Hi Guys,
I have the following code to extract the details out of a record. The query worked fine for "Family", however it kept telling me that "classNumber" was not an existing field.
I spent ages trying to workout why not! However I decided to recreate the field as classnumber (all lowercase) and it works fine!! Any thoughts? Is there a way that I can leave all my fields as upper case? Otherwise I need to go through and create all lower case versions of my fields to make it work.
@api.onchange('templateProduct')
def templateProduct_onchange(self, templateProduct):
self._cr.execute("SELECT family, classNumber FROM npirequest_npirequest WHERE id="+str(templateProduct))
result = self._cr.dictfetchone()
Thanks,
Damien
It is discouraged using SQL queries (Bypass the ORM).
> You should never use the database cursor directly when the ORM can do the same thing! By doing so you are bypassing all the ORM features, possibly the transactions, access rights and so on.
Source: https://www.odoo.com/documentation/10.0/reference/guidelines.html#programming-in-odoo
Thanks komit for giving this link www.odoo.com/documentation/10.0/reference/guidelines.html#programming-in-odoo .