in odoo 13,I have a custom SQL query,as follows:
select * from test_table1 where number = self.number and (name=self.name or spec = self.spec) order by ( case when name=self.name then 1 else 0 end + case when spec=self.spec then 1 else 0 end ) desc
I want to know how to express the complex where and order Part with odoo's ORM?
In fact, my business is that I have a button in the form. After clicking the button, I get the form field parameters in the background, and then perform the above fuzzy query to return to a tree view or table
def action_genmatchlist(self): return {'name': 'Gen Match List', 'type': 'ir.actions.act_window', 'views': [[False, 'tree']], 'res_model': 'test.table1', 'target': 'new', 'domain': [('number','=',self.number)], #'order':???, }
so,I have three questions about this.
1、how to express the where and order Part with odoo's ORM?
2、Can I sql query data by format first, and then attach the data to act_ Window parameter?
3、How to return sql query data to web ,use table template.