Hey Cyllo community! How can I trigger a server-side action in Cyllo when a specific field in a record is updated?
Welcome!
Share and discuss the best content and new marketing ideas, build your professional profile and become a better marketer together.
This question has been flagged
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'