Odoo Help

2

1
4 Answers
2
Avatar

Yenthe Van Ginneken Belgium

--Yenthe Van Ginneken--
25128
| 9 9 12
Turnhout, Belgium
--Yenthe Van Ginneken--


Yenthe Van Ginneken Belgium
1/8/19, 8:31 AM

Hi Sugeesh,

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 logic comes here')

Regards,
Yenthe

1 Comment
Sugeesh Ps India
5/29/19, 7:43 AM

@Yenthe Van Ginneken,

Could you please explain how to set a server action for "MENU ITEMS"

1
Avatar

Mitul Shingala India

--Mitul Shingala--
5344
| 6 4 9
Vadodara, Gujarat, India
--Mitul Shingala--

Odoo Developer

Mitul Shingala India
1/8/19, 8:41 AM

hello , try like below code

<act_window
            id="action_account_payment_from_invoices"
            name="Register Payment"
            res_model="account.register.payments" # which object's view you want to open
            src_model="account.invoice" # on which object's view you want to add
            view_mode="form" 
            multi="True" 
            target="new"
            key2="client_action_multi"
        />
Ask a Question
Writer
Tag
Keep Informed
1 follower(s)
About This Community

This platform 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.

Register
Odoo Training Center

Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now