Help

欢迎!

该社区面向专业人士和我们产品和服务的爱好者。
分享和讨论最好的内容和新的营销理念,建立您的专业形象,一起成为更好的营销人员。


0

when i use @api.model?

Avatar
odoo
2 Comments
Avatar
Discard
Avatar
odoo
-

thank you Waleed Mohsen

can u give me information about all of the api in odoo 15
it is possible for you?

Avatar
odoo
-
1 Answer
0
Avatar
odoo
Best Answer

@api.model decorator used on methods for which only the model is important, not the contents of the recordset. so self should be used as a reference for the model, without expecting it to contain actual records.
In another words it's used when you need to do something with model itself and don't need to modify/check some exact model's record/records

@api.depends(fld1,...) is used for computed field functions, to identify on what changes the (re)calculation should be triggered. It must set values on the computed fields, otherwise it will error.

@api.onchange(fld1,...) is used in the user interface, to automatically change some field values when other fields are changed. The self argument is a singleton with the current form data, and the method should set values on it for the changes that should happen in the form. It doesn’t actually write to database records, instead it provides information to change the data in the UI form.

1 Comment
Avatar
Discard
Avatar
odoo
-

What if I don't declare @api.model?
What will happen?
I try to remove it but there is no effect after it.