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.
Diese Frage wurde gekennzeichnet
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.
Diskutieren Sie gerne? Treten Sie bei, statt nur zu lesen!
Erstellen Sie heute ein Konto, um exklusive Funktionen zu nutzen und mit unserer tollen Community zu interagieren!
Registrieren| Verknüpfte Beiträge | Antworten | Ansichten | Aktivität | |
|---|---|---|---|---|
|
|
1
Sept. 23
|
6706 | ||
|
|
1
Okt. 16
|
12604 | ||
|
|
1
März 15
|
7218 | ||
|
|
3
März 24
|
20015 | ||
|
|
2
Juni 22
|
5766 |
Will this help ? https://www.youtube.com/watch?v=GYn1J80xZh8