On Odoo 12, Im trying run self._cr.execute
on compute but return me Null
, I tried domain and is working but because the Query i will use is complex i need to do it with SQL Query.
_inherit ='purchase.order.line'
partner1 = fields.Many2one('res.partner', string='Vendor 1', compute='_compute_vendors', copy = True, store=True, readonly= False)
partner2 = fields.Many2one('res.partner', string='Vendor 2', compute='_compute_vendors', copy = True, store=True, readonly= False)
partner3 = fields.Many2one('res.partner', string='Vendor 3', compute='_compute_vendors', copy = True, store=True, readonly= False)
@api.depends('product_id')
def _compute_vendors(self):
vendors = []
vendors.append(self._cr.execute("""SELECT partner_id FROM purchase_order_line"""))
Any solution?
Execute return None
, to retrieve the selected records you can use fetchall:
# first execute the query
self._cr.execute("""SELECT partner_id FROM purchase_order_line""")
# fetc rows
vendors = [r[0] for r in self._cr.fetchall()]