KbiR KbiR - 5 months ago 19
Python Question

Odoo8-Call a python function from menuitem and rereturn a URL?

I tried to call python function from menuitem and return a URL?
It successfully get into function but didn't return anything, No error.
My code :

In py:

def browse_ftp(self, cr, uid, ids, context=None):
fi_url='http://www.google.com'
print'Final Url',fi_url // It print url
return {
'type': 'ir.actions.act_url',
'url':fi_url,
'target': 'self'
}


In vew.xml:

<record id="action_make_testing" model="ir.actions.server">

<field name="name">Test Browsse File</field>

<field name="condition">True</field>

<field name="type">ir.actions.server</field>

<field name="model_id" ref="model_document_ftp_browse" />

<field name="state">code</field>

<field name="code">self.browse_ftp(cr, uid, context.get('active_ids',
[]), context=context)</field>

</record>


Menuitem:

<menuitem name="Test " action="action_make_testing" id="menu_test"
icon="STOCK_EXECUTE" parent="knowledge.menu_document_configuration"
sequence="135" />

Answer

I have modified ir.action.server view like below:

 <record id="action_make_testing" model="ir.actions.server">

    <field name="name">Test Browsse File</field>

    <field name="condition">True</field>

    <field name="type">ir.actions.server</field>

    <field name="model_id" ref="model_document_ftp_browse" />

    <field name="state">code</field>

    **<field name="code">
           action = self.browse_ftp(cr, uid, context.get('active_ids',
        []), context=context)</field>**

</record>
Comments