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.
La domanda è stata contrassegnata
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.
Ti stai godendo la conversazione? Non leggere soltanto, partecipa anche tu!
Crea un account oggi per scoprire funzionalità esclusive ed entrare a far parte della nostra fantastica community!
Registrati| Post correlati | Risposte | Visualizzazioni | Attività | |
|---|---|---|---|---|
|
|
1
set 23
|
6655 | ||
|
|
1
ott 16
|
12568 | ||
|
|
1
mar 15
|
7196 | ||
|
|
3
mar 24
|
19996 | ||
|
|
2
giu 22
|
5715 |
Will this help ? https://www.youtube.com/watch?v=GYn1J80xZh8