Odoo Help

Welcome!

This community is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.

0

Get current active view_id

By
Munesh Nandwani
on 11/29/16, 8:05 AM 95 views

Is there a way to get the current active view_id? I need to refresh the page according to the active form that user are viewing. Or is there a way for me to refresh 2 or more page? (parent and wizard view)

I have tried:

@api.multi
def refresh_ot(self, activity):

    ir_model_data = self.env['ir.model.data']
    form_res = self.env.ref('mrp_employee_relation.mrp_employee_activity_form_view')
    tree_res = self.env.ref('mrp_employee_relation.mrp_employee_activity_tree_view')

return { 'view_mode': 'form', 'view_type': 'form', 'res_model': 'mrp.employee.activity', 'res_id' : activity.id, 'view_id' : False, 'views' : [(form_res.id, 'form'), (tree_res.id, 'tree')], 'type' : 'ir.actions.act_window', }


@api.multi
 def refresh_plat(self, plating):
    ir_model_data = self.env['ir.model.data']
    form_res = self.env.ref('mrp_employee_relation.mrp_plating_report_form_view')
    tree_res = self.env.ref('mrp_employee_relation.mrp_plating_report_tree_view')

return { 'view_mode': 'form', 'view_type': 'form', 'res_model': 'mrp.plating.report', 'res_id' : plating.id, 'view_id' : False, 'views' : [(form_res.id, 'form'), (tree_res.id, 'tree')], 'type' : 'ir.actions.act_window', }


Then I call both function at Return, this method only work if I am in wizard view and it wont work if I am using the parent view while pressing a object button. 



0

Jignesh Mehta

--Jignesh Mehta--
2087
| 6 4 8
Surat, India
--Jignesh Mehta--


Jignesh Mehta
On 11/29/16, 10:56 PM

Hello Munesh Nandwani,


Try below code.


@api.multi

def refresh_plat(self, plating):

     model_obj = self.env['ir.model.data']

     data_id = model_obj._get_id('module_name', 'view_id_which_you_want_refresh')

     view_id = model_obj.browse(data_id).res_id

     return {

         'type': 'ir.actions.client',

         'tag': 'reload',               

         'name': _('View Name'),               

         'res_model': 'model_name',               

         'view_type': 'view type which is kanban, form',               

         'view_mode': 'view mode which is kanban, form',               

         'view_id': view_id,               

         'target': 'current',               

         'nodestroy': True,

     }


Hope it will works for you.

Thanks,


Hi Jignesh Metha,

Thank you for you reply. But it's not the solution that I am looking for. I wish I can upload a picture to have a clearer view of the situation.

What happen is, In From Employee Activity I have one2many of Plating. In that one2many tree I have a button name "start". If u click the one2many it will pop up a wizard that will have the same button (start).

If use the button inside the wizard and I call both refresh function. It work properly. But if I use the button inside the one2many (without having a pop out wizard) it will not refresh properly (it only refresh that one2many not other one2many that are created because of that start button).

So If i can find out currently the user is using the start button from wizard view or not wizard view I can call the function accordingly. I hope this clarifies my question. Thank you.

Munesh Nandwani
on 11/30/16, 12:18 AM

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

1 follower(s)

Stats

Asked: 11/29/16, 8:05 AM
Seen: 95 times
Last updated: 11/29/16, 10:56 PM