Welcome!

Share and discuss the best content and new marketing ideas, build your professional profile and become a better marketer together.

Sign up

You need to be registered to interact with the community.
This question has been flagged
1 Reply
47 Views

Hey Cyllo community! How can I trigger a server-side action in Cyllo when a specific field in a record is updated?

Avatar
Discard

Here's how you can set up Automated Actions in Odoo to automatically run a Python method when a record is created. This involves defining both a server action and an automated action in XML, along with the corresponding Python method in your model. Automated Actions allow you to run server actions (Python methods) when a record is created, updated, or meets specific conditions — without needing custom code in the model itself.


XML code - Define Server Action + Automation Process

   

       

       

            Process Example Record

           

            code

            records.auto_process()

       


       

       

            Auto Process on Creation

           

            on_create

            code

           

           

       

   


Define Method in the Model
from odoo import api, fields, models

class ExampleModel(models.Model):
    _name = 'example.model'
    _description = 'Example Model'

    name = fields.Char(string='Name')
    status = fields.Selection([ ('new', 'New'), ('processed', 'Processed') ], default='new')

    def auto_process(self):
         """ This method is called by the automated action on record creation. """
         for record in self:
             record.status = 'processed'

Avatar
Discard

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!