Hi,
I need to include a menu in the action menu of the model account.invoice and i want to call a button function of the same model without any wizards,how can i do this
Thanks in advance
Odoo is the world's easiest all-in-one management software.
 It includes hundreds of business apps:
Hi,
I need to include a menu in the action menu of the model account.invoice and i want to call a button function of the same model without any wizards,how can i do this
Thanks in advance
Hi,
You can do this with an XML record defined as a ir.actions.server and then binding it to an ir.values record. Example in XML:
<record model="ir.actions.server" id="your_custom_action_id">
    <field name="name">Your description here</field>
    <field name="model_id" ref="your_module.model_your_model_name"/>
    <field name="code">
        for item in records:
        item.your_function()
        </field>
</record>
<record model="ir.values" id="ir_value_your_custom">
    <field name="model_id" ref="your_module.model_your_model_name"/>
    <field name="name">Your title here (shown to user)</field>
    <field name="key2">client_action_multi</field>
    <field name="value" eval="'ir.actions.server,' +str(ref('your_custom_action_id'))"/>
    <field name="key">action</field>
    <field name="model">your.model.name</field>
</record>
You can then create a Python function to execute code when the user clicks on this action:
@api.multi def your_function(self):
  print('Your custom Python function')
Regards
Actually, in version 12 you have a key in ir.actions.server called "binding_model_id". With that key you don't need to define the second record.
Regards
Créez un compte dès aujourd'hui pour profiter de fonctionnalités exclusives et échanger avec notre formidable communauté !
S'inscrire| Publications associées | Réponses | Vues | Activité | |
|---|---|---|---|---|
|  | 1 oct. 21  | 4884 | ||
|  | 1 janv. 21  | 3608 | ||
|  | 2 oct. 20  | 4768 | ||
|  | 3 mai 20  | 6044 | ||
|  | 0 juil. 19  | 3480 |