Server action is an new feature to the OpenERP available since the version 5.0 beta. This features enables to provides the quick and easy configuration some process which is day to day requirements: Like a block of python code that will be executed, send a signal to a workflow, update the values of a record, choose a client action to launch etc.
Below is example of server actions in odoo10. How to create a method using python which will trigger using server action:
Implemenation in Python:
project_ids = self.env[‘project.project’].search()
_logger.info(‘ Changing Project Type : Successful’)
_logger.info(‘ Changing Project Type : Failed’)
Implemenation in XML:
<record id="action_server_change_project_type" model="ir.actions.server"> <field name="name">Change Project Type</field> <field name="model_id" ref="project.model_project_project"/> <field name="code"> action = model.compute_project_type() </field> </record>
- name : Automated Server Action Name,
- model_id : Format to define model_id module.model_model_name,
- Here Project is Module where automated server action is created,
- In model_project_project : “model_” is prefix and “model_name” is model name where automated server action will be triggered,
- code : A piece of Python code to execute when the action is called.
On the Settings top menu, select the Technical / Actions/ Server Actions menu item:
The following screenshot shows the form of my action server.
To use it from the More menu in your model, click on “Add in the ‘More’ menu” button.
What am I missing here? Let me know in the comments and I’ll add it in 😉