- Odoo 11 Development Essentials(Third Edition)
- Daniel Reis
- 243字
- 2021-08-27 19:32:47
Model attributes
Model classes can use additional attributes that control some of their behaviors. These are the most commonly used attributes:
- _name is the internal identifier for the Odoo model we are creating. Mandatory when creating a new model.
- _description is a user-friendly title for the model's records, shown when the model is viewed in the user interface. Optional but recommended.
- _order sets the default order to use when the model's records are browsed, or shown in a list view. It is a text string to be used as the SQL order by clause, so it can be anything you could use there, although it has smart behavior and supports translatable and many-to-one field names.
For completeness, there are a couple more attributes that can be used in advanced cases:
- _rec_name indicates the field to use as the record description when referenced from related fields, such as a many-to-one relationship. By default, it uses the name field, which is a common field in models. But this attribute allows us to use any other field for that purpose.
- _table is the name of the database table supporting the model. Usually, it is left to be calculated automatically, and is the model name with the dots replaced by underscores. But it's possible to set it to indicate a specific table name.
We can also have the _inherit and _inherits attributes, used to extend modules. We will look closer at them later in this chapter.
推薦閱讀
- 五筆打字精品教程
- Excel 2010在會計與財務管理日常工作中的應用
- 新編電腦辦公(Windows 10 + Office 2010版)從入門到精通
- Excel 2016辦公專家從入門到精通(視頻自學版)
- Excel/PPT 2016辦公專家從入門到精通
- 普通WPS Word規范排版公文格式
- 從零開始學Excel VBA
- PPT2013制作超級應用大全(實戰案例版)
- Word 2007辦公應用融會貫通
- 情感化PPT設計(微視頻版)
- 人事管理政務網上公開的發展與對策
- 掌中寶:Word辦公應用技巧
- Word/Excel/PowerPoint三合一實戰辦公技巧
- 炫舞Power Point:PPT動畫創意設計
- Excel數據處理與分析