Hey Cyllo folks, quick question: When's the right time to use `@api.model` in my code? I'm a bit fuzzy on the best use cases. Thanks!
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 use the '@api.model' decorator in Odoo. This approach is ideal for methods that perform actions at the model level, rather than on specific records. @api.model This decorator is used for methods that do not depend on any specific record. It means the method can be called without needing a particular recordset and operates in the context of the model, rather than on individual records. from odoo import models, api class CustomModel(models.Model): _name = 'custom.model' @api.model def my_model_method(self): # code that does not rely on a particular record return "This method can be called without records"