I try build a module global_search now i stuck at how to store data in TransientModel from a query in a function to render treeview
this is my py code but self.write not work
# -*- coding: utf-8 -*-
from odoo import models, fields, api
class CreateViewSql(models.TransientModel):
_name = "create.view.sql"
email = fields.Char(string='Email')
name = fields.Char(string='Name')
phone = fields.Integer(string='Phone')
# type_of = fields.Char(string='Type')
@api.model
def get_data(self, search):
text_input = search.get("Input")
sql = "select name,email,phone from res_partner where phone = '%s' or email = '%s'"
self.env.cr.execute(sql)
result = self.env.cr.fetchall() or []
vals = {}
now i need store result 3 fields(name, email, phone) to TransientModel
vals = {}
vals['name'] = result[0][0]
vals['email'] = result[0][1]
vals['phone'] = result[0][2]
self.write(vals)
return result
now i need store result 3 fields(name, email, phone) to TransientModel