Hello,
I have a python function that returns a treeview but it's not a normal treeview, I can't create or select some records.
How to return a normal treeview ?
Python function :
@api.multi
@api.model
def chargement_ratio(self):
productRatio = self.env['miadi.poidsconditionnement']
conditionnements = self._cr.execute("SELECT id FROM miadi_packaging")
query_cond = self.env.cr.dictfetchall()
produits = self._cr.execute("SELECT id FROM product_product")
query_prod = self.env.cr.dictfetchall()
for conditionnements in query_cond:
nom_conditionnement = conditionnements['id']
for produits in query_prod:
product = produits['id']
if_exist = self._cr.execute("SELECT * FROM miadi_poidsConditionnement WHERE conditionnement_id=%s AND produit_id=%s", (nom_conditionnement, product))
exist = self.env.cr.dictfetchall()
if not exist:
Ratio = productRatio.create({'conditionnement_id': nom_conditionnement, 'produit_id': product})
return {'name': _('Weight/number Ratio'), 'view_type': 'tree', 'view_mode': 'tree', 'view_id': self.env.ref('miadi_packaging.miadi_poidsConditionnement_tree').id, 'res_model': 'miadi.poidsconditionnement', 'type': 'ir.actions.act_window', 'target': 'current',}
The treeview returned by the function : https://www.hostingpics.net/viewer.php?id=651454Capturetreeview3.png
What I want :https://www.hostingpics.net/viewer.php?id=947270Capturetreeview2.png
I'm on Odoo 10
Thanks for answers