Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to open different website with act_window openerp

Tags:

openerp

I need to open website from the UI of OpenERP project, for example google.com. It must be in act_window tag. How to pass parameters dynamicly in URL , for example http://www.google.bg/?q=sun?

like image 488
user1047025 Avatar asked Nov 15 '11 07:11

user1047025


2 Answers

Since you need it to be dynamic, you need to create a method and return an dictionary of ir.actions.url. Then just attach this method to a button. (Note: you may need to open a wizard with the button on it if you need to have the main button on the sidebar).

from openerp import models, api

class MyClass(models.Model):
    _name = "my_module.my_class"

    @api.multi
    def openURL(self):
        q = "sun"
        return {
            'type': 'ir.actions.act_url',
            'url': "http://www.google.bg/?q=%s" % q,
            'target': 'new', # open in a new tab
        }

In your view XML:

<button name="openURL" string="Open URL" type="object">

the name attribute is the name of the method to call

like image 125
macdelacruz Avatar answered Sep 22 '22 19:09

macdelacruz


I do not know either it can possible with act_window or not. but I'm sure that we can open url through ir.actions.url model.

I do not tried it. but the hint can guide you.

1) create action record with ir.actions.url model and url

2) create menuitem for the same action with type='url'

3) you need to create wizard to open particular url address. with

'type': 'ir.actions.act_url' and

'url':"web address" in return values.

hope, it could help you.

like image 37
Yajushi Avatar answered Sep 19 '22 19:09

Yajushi