Odooers论坛

欢迎!

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


0

when i use @api.model?

形象
odoo
2 注释
形象
丢弃
形象
odoo
-

thank you Waleed Mohsen

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

形象
odoo
-
1 答案
0
形象
odoo
最佳答案

@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 备注
形象
丢弃
形象
odoo
-

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