3

I searched through the old forums and didn't find any decent answers. Is it possible to click on a record in a one2many list and have it open the full page, rather than just the popup?

If yes, where else i can make changes in the code ?

I'm trying to access attachments/reports/links associated with that record, and that's not possible if I'm only ever getting a popup window.

Thanks for your input.

aru
  • 71
  • 1
  • 10
  • I think this option is not available out of the box in Odoo. so you may need customization – kerbrose Sep 08 '20 at 03:55
  • is there any example or a document to customize the same in odoo V13 ? Steps kind of – aru Sep 08 '20 at 03:56
  • You can use a button i' the tree view to open the record, or you can use a button to open record that are in one2many field, like for example smart buttons – Charif DZ Sep 08 '20 at 06:06
  • Button in the sense, for all the records? If i have 10 records for a model which is already in tree view then if i click on single record it should give a form view in the current window instead of pop up. Is that what you are talking about? if yes, do you have any document for the same? – aru Sep 08 '20 at 06:30
  • I didn't have time to write the answer, but I think @arryph understood the idea – Charif DZ Sep 08 '20 at 15:39

2 Answers2

2

You can use button to achieve this in form view list. The button type has to be object and it will return ir.actions.act_window type action.

Add following button inside the tree tag:

<button name="open_action" string="Open" type="object" class="oe_highlight"/>

Add this function to the model:

def open_action(self):
  return {
    'name': self.display_name,
    'type': 'ir.actions.act_window',
    'view_mode': 'form',
    'res_model': self._name,
    'res_id': self.id,
    'target': 'current
}

Note that target current ensure the object will open in current window. Target new opens in a modal popup.

arryph
  • 2,725
  • 10
  • 15
  • could you please tell the use case of self.display_name() ?? – aru Nov 13 '20 at 04:48
  • I see after setting the target to 'current' i see it is opening as a 'Popup' window, which is already happening when clicking on the record without button. when added 'new' it is showing error with display_name() in odoo V13 – aru Nov 13 '20 at 05:16
  • updated answer, it will be `self.display_name`. it just displays the name of the record as title of the popup. you can replace with any fixed string, like `'name': 'Popup'`. – arryph Nov 13 '20 at 10:07
0

As of this writing, in Odoo 15, it is still not possible to do that directly. You need to add a button in the view, but that can be done easily in the view XML only:

<tree no_open="1">
  <field name="name"/>
  <button name="get_formview_action" string="View" type="object" class="btn-primary"/>
</tree>

With no_open="1", clicking on a line in the tree will not open the popup. get_formview_action is a Python method that already exists in Odoo for all models, and you don't have to write yourself.

Jerther
  • 5,558
  • 8
  • 40
  • 59