ช่วยเหลือ

2

Redirect to tree view with Controller

Avatar
Rado Harilala

How to redirect a link to a tree view of a model by using Controller?

I tried this but doesn't work:

@http.route('/library/view_rents', auth='public', website="true")

def view_rents(self, **kw):

return {

"type": "ir.actions.act_window",

"res_model": "library.rental",

"views": [(False, "tree"), (False, "form")],

"target": "new",

        }

1 ความคิดเห็น
Avatar
Discard
Avatar
Niyas Raphy
-

auth='public",

how can you make a public user to access the backend

4 Answers
4
Best Answer

Hi Rado,

You can redirect a user to specific URL. The URL should be the URL of your tree view.

EX:

action_id = request.env.ref('module_name.xml_id_of_action')
return request.redirect('/web?&#min=1&limit=80&view_type=list&model=sale.order&action=%s' %(action_id))
OR
import werkzeug.utils
werkzeug.utils.redirect('/web?&#min=1&limit=80&view_type=list&model=sale.order&action=%s' %(action_id))
Sudhir Arya
ERP Harbor Consulting Services
Skype:sudhir@erpharbor.com
Website: http://www.erpharbor.com
Avatar
Discard
2
Avatar
Sehrish
Best Answer

try this one:

        return {
         'type': 'ir.actions.act_window',
         'res_model': 'your_model_name',          'view_type': 'form',          'view_mode': 'tree,form',          'views': [(view_id_tree[0].id, 'tree'),(False,'form')],          'view_id ref="your_module_name.your_view_id"': '',          'target': 'current',          'domain': domain,         }


1 ความคิดเห็น
Avatar
Discard
Avatar
Sehrish
-
0
Avatar
Emipro Technologies Pvt. Ltd.
Best Answer

Hello Rado,

You can redirect from controller to Tree view as following:

import werkzeug

return werkzeug.utils.redirect('/web#view_type=list&model=library.rental&action=155')

action=action_id of your menu of model


Thanks,

Avatar
Discard
0
Avatar
David Peralta
Best Answer

Hello
Redirect without controller

Example in modules files addons odoo 10.0:

addons/website/views/website_templates.xml:

<a t-attf-href="/web#action=base.action_view_base_language_install&amp;website_id=#{website.id if website else ''}&amp;url_return=#{url_return}">

addons/website_twitter/static/src/xml/website.twitter.xml

<a class="lnk_configure" href="/web#action=website.action_website_configuration">Twitter Configuration</a>
addons/website_theme_install/views/views.xml

<a href="/web#action=website_theme_install.theme_install_kanban_action">See themes here</a>
Regards

Avatar
Discard