I created a button and this button call similar_list_button_action and will show tree view with dynamic data.How can I do that?Here is my code.
In .py File
#Function called by button
@api.multi
def similar_list_button_action(self):
tree_view_id = self.env.ref('similar_contact.similar_detail_tree_view').id
a=self.env['similar.task'].search([('active_ids','!=','0')]) #Search id that is not equal 0
b=self.env['similar.task'].search([('sname','!=','')]) # Search name that is not equal null
c=self.env['similar.task'].search([('semail','!=','')]) # Search email that is not equal null
d=self.env['similar.task'].search([('sphone','!=','')]) # Search phone no that is not equal null
logging.info(a) # similar.task(602, 606, 610)
logging.info(b) #similar.task(603,607,611)
logging.info(c) # similar.task(608,)
logging.info(d) # similar.task(609)
for x in a:
logging.info(x.active_ids) ## get id values 41,42,43
for y in b:
logging.info(y.sname) ## get name values of each id
for z in c:
logging.info(z.semail) # get email values of each id
for w in d:
logging.info(w.sphone)# get phone of each id
return{
'name' : 'Similar Detail Tree View',
'type' : 'ir.actions.act_window',
'res_model' : 'similar.task',
'view_type' : 'form',
'view_mode' : 'tree',
'view_id' : [(tree_view_id,'tree')],
#'res_id' : my_id,
'target' : 'current'
}
When I loop x,y,z,w, I got the data what I want.I want to show these data in each columns of tree view like this.
name email phone
b.sname c.semail d.phone
b.sname c.semail d.phone
#In .py file I created a model too.
class similar_detail(models.Model):
_name="similar.task"
sname=fields.Char(string="Name")
semail=fields.Char(string="Email")
sphone=fields.Char(string="Phone")
active_ids=fields.Integer(string="Active")
Thank You.