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

How to navigate back in view history (SOLVED)

By
Pau Ubach
on 10/10/14, 2:12 AM 842 views

This question is related to:
https://www.odoo.com/forum/help-1/question/open-a-form-view-for-a-specific-record-or-go-back-to-previous-view-64998

When I'm navigating between views, in the header I can see this history:

Example: Opportunities / New oportunity / Administrator 
Clicking in New oportunity would navigate one view back, clicking in Opportunities would navigate 2 views back.

How can I do this automatically from a function in python? 

I have managed to create a new view, but can't go back to last view.

Thanks,
Pau

 

0
Pau Ubach
On 10/14/14, 2:28 AM

I managed to solve it!! (where's the smiley of infinite happiness?)

I just navigate back in browser history.

For this I need to create an action: 

        <record model="ir.actions.client" id="action_client_back">
            <field name="name">instance.bdt.Back</field>
            <field name="tag">bdt.back</field>
            <field name="params">{}</field>
        </record>

and the JS function:

openerp.request_project = function(instance) {
    instance.request_project = {};
    instance.request_project.back = function(){
        window.history.back();
    };
    instance.web.client_actions.add('bdt.back', 'instance.request_project.back');
}

So, when I finish what button does I can return back:

return {'type': 'ir.actions.client', 'tag': 'bdt.back'}
0
Zyphos
On 4/6/16, 3:38 AM

To navigate back in history,

you don't need to create a new function. It is already in Odoo.

Just add at the end of your button python function:

return {'type': 'ir.actions.client', 'tag': 'history_back'}

0

deep

--deep--
1617
| 5 4 7
Bengaluru, India
--deep--

Techno-Functional Associate with 6+ years of experience in Odoo (formerly known as OpenERP).

deep
On 10/10/14, 3:17 AM

If you are meaning, to load a particular action...

then in your return statement of the function, return the action / ir_act_window...

Example:

model_obj = self.pool.get('ir.model.data')
        
form_view = model_obj._get_id(cr, uid, 'MODULE_NAME', 'XML_VIEW')
if form_view:
            form_view = model_obj.browse(cr, uid, form_view, context=context).res_id

return {
                    'view_type' : 'form',
                    'view_mode' : 'form',
                    'res_model' : 'MODEL',
                    'res_id'    : False,
                    'view_id'   : False,
                    'views'     : [(form_view, 'form'), ],
                    'type'      : 'ir.actions.act_window',
                    'target'    : 'current',
                  }

You can also refer in standard, Invoice to Refund option as well, in which when an invoice is refunded, it loads action of Refunds...

Hi deep, thanks but I don't mean it. You can check the link to the other question.

Pau Ubach
on 10/10/14, 4:29 AM

Now I do as you described, and the problem is that I get a new element in the navigation history instead of deleting the last one.

Pau Ubach
on 10/10/14, 4:31 AM

add reload: True in the value list

deep
on 10/10/14, 4:54 AM

'tag': 'reload',

deep
on 10/10/14, 4:55 AM

Could you clarify last answer?

Pau Ubach
on 10/10/14, 4:56 AM

If still the problem persists, then you can write you own widget to do the same....

deep
on 10/10/14, 4:57 AM

I didnt get... which one?

deep
on 10/10/14, 5:03 AM

I tried reload, but it doesn't go to the previous view, it just refresh the new one.

Pau Ubach
on 10/10/14, 5:05 AM

Thanks anyway deep.

Pau Ubach
on 10/10/14, 5:50 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: 10/10/14, 2:12 AM
Seen: 842 times
Last updated: 4/6/16, 3:38 AM