0

I have added a button to a purchase order header form. Whenever I click on the button, it triggers a method. The method runs the following raw query. An odoo list view shows the data in a list.

cr.execute("SELECT * FROM stock_move WHERE origin=%s", (po_name,))
s_moves = cr.fetchall()

s_moves has a list of data. I want to view it in the list view in odoo 8. I want to generate this list with python. Somehow I need to use "ir.actions.act_window" in python and bind my data. But I do not know how to do it? And whenever click on the single list item, the detail page view will appear.

KbiR
  • 4,047
  • 6
  • 37
  • 103
Shahjalal
  • 1,163
  • 7
  • 21
  • 38

1 Answers1

0

return an action on your button function by changing the query like

cr.execute("SELECT id FROM stock_move WHERE origin=%s", (po_name,))
s_moves = cr.fetchall()

return {
    'name': _('Name'),
    'view_type': 'form',
    'view_mode': 'tree,form',
    'res_model': 'Model.Name',
    'view_id': False,
    'views': [(False,'tree'),(False,'form'),],
    'domain': [('id', 'in', s_moves)]
    'type': 'ir.actions.act_window',
}
Hilar AK
  • 1,655
  • 13
  • 25