Question says all. I've created SQL tree view that displays some data. When I click on one of the rows, it doesn't redirect me to the form view. The view fields are just Many2ones that reference main model.
Această întrebare a fost marcată
Hi,
The issue is that clicking a row in a tree view redirects to the form view of that same model. If your tree is built on a custom SQL view/model, Odoo looks for a form view on that model; which doesn't exist, so nothing happens.
To redirect to the form view of the main model (the one the Many2one points to), you have two options:
Option 1; Add open_rec method on the SQL model:
def open_record(self):
return {
'type': 'ir.actions.act_window',
'res_model': 'your.main.model',
'view_mode': 'form',
'res_id': self.main_model_id.id,
'target': 'current',
}
Then add a button in the tree view that calls it.
Option 2; Use optional Many2one column with built-in redirect:
In your tree view XML, make the Many2one field clickable by ensuring it's a proper many2one widget; clicking it natively opens the related record's form view:
<field name="main_model_id" />
Clicking the Many2one value in the list will open the linked record's form directly; no extra code needed.
Option 2 is the simplest if you just need the user to navigate to the related record.
Îți place discuția? Nu doar citi, alătură-te!
Creează-ți un cont astăzi pentru a beneficia de funcții exclusive și a interacționa cu minunata noastră comunitate!
Înscrie-te| Postări similare | Răspunsuri | Vizualizări | Activitate | |
|---|---|---|---|---|
|
|
1
sept. 23
|
6668 | ||
|
|
1
oct. 16
|
12575 | ||
|
|
1
mar. 15
|
7201 | ||
|
|
3
mar. 24
|
19999 | ||
|
|
2
iun. 22
|
5724 |
Will this help ? https://www.youtube.com/watch?v=GYn1J80xZh8