- 上传者: Administrator
- 上传时间:2023年11月12日 23时58分39秒
* Model Attributes ** *** These are the features that are defined during the time of the creation of a new model or using the model which are already ......
Model Attributes
These are the features that are defined during the time of the creation of a new model or using the model which are already existing. Let us see the model attributes in Odoo
_auto = false - Whether we create a new database table that is set to False, override init() to create the database table. It automatically defaults to True for models and Transient models and False for Abstract models.
_log_access - Whether the ORM should automatically generate and update the Access Log Files. Defaults to whatever value was set for _auto.
_table = None - if _auto, it is the SQL table name used by the model.
_sequence = None - SQL sequence, which is used for an ID field.
_sql_constraints = [] - SQL constraints [(name, sql_def, message)].
_register = False - registry visibility by default is false.
_abstract = True - To check whether the model is an abstract model.
_transient = True - To check whether the model is a Transient model.
_name = None - the name of the model.
_inherit = () - we use the inherited attribute when we want to use a model that is already in the database.
_description = None - informal name of the models.
_inherits = {} - dictionary {‘parent_model’: ‘m2o_field’} mapping the _name of the parent objects to the names of the corresponding foreign key fields to use.
_rec_name = None - used for labeling records. By default, it is the name of the record.
_order = ‘id’ - Default order field for searching results.
_check_company_auto = False - On write and create, call _check_company to ensure companies consistency on the relational fields having check_company=True as an attribute.
_parent_name = ‘parent_id’ - The many2one field used as parent field
_parent_store = false - Set to True to compute parent_path field.
_date_name = ‘Date’ - used for default calendar view.
_fold_name = ‘fold’ - used to determine folded groups in kanban views.
Scaffold command
In Odoo, it is the process of creating a skeletal structure for a module. We can automatically design module structures using Odoo scaffolding. It saves lots of time. A module is usually a directory within a module directory. The addons path specifies the module path. Let us see how it can be done. For that, first, let us build a new module under /opt/odoo/custom add-ons, such as custom add-ons. In order to create a module structure, first of all, we must go to the Odoo-bin location using the terminal.
Enter the scaffold command to create a sample module structure. The command is given below.
./odoo-bin scaffold module_name folder_name
module_name: Name of the module
folder_name: Directory name inside which you want to create the module.
Normally, Within a module directory, a module is a directory. The addons path specifies the module path. In order to begin, create a new module in /opt/odoo/custom addons, For example, custom addons. For creating a module structure, we must first go to the odoo-bin location using the terminal. In order to automatically generate a module structure, run the following command given below:
./odoo-bin scaffold new_module custom_addons
By executing the above command, it creates a new module with some directories.
Expanded view of the module.
Each module contains two required python files i.e., ‘__init__.py’ and ‘__manifest__.py’ files.
As we can see in the above image, each directory inside the module will be created by itself. It is possible to make changes to the content that is required.
1. The python files contained within the module are models.
2. Views are the XML files that help to display the records.
3. Data consists of demo data that are needed in the module. It contains XML that creates/updates databases.
4. The security file consists of configured files of access rights.
5. The __init__.py file imports all the python files defined in the module.
6. We use controllers when we need to render data to the website.
本文章从网上收集,如有侵权请联系tderp@tderp.com删除
- 微信扫一扫,一分也是爱:
服务原则及地区范围
宜兴通达网络科技有限公司,地处中国宜兴环科园内,是一家高新技术企业。公司在企业网络维护和企业信息化建设与咨询方面,有10多年经验。
我公司愿与客户一道,力求彻底解决客户问题!
我们不是在给企业提供“头痛医头、脚痛医脚”的暂时解决方案,而是在部署根本性安全与稳定服务!!
我们愿携手客户,建立企业IT规划;杜绝随意安装系统、软件等操作;力求共同维护有序、安全、稳定的网络办公环境!!!
IT服务,服务是根本,客户是上帝;我们提供快速响应、快速上门、快速排查,提供优质高效的服务!!!!
通达科技提供全国范围内的服务,服务形式包括远程协助、电话咨询、电子邮件咨询、传真咨询、问答平台的问题解决等。
宜兴地区提供上门服务:
- 市区服务:宜城街道、城北街道(屺亭街道)、新街街道、新庄街道、环科园、渚桥开发区
- 市郊服务:张渚镇、西渚镇、太华镇、徐舍镇、官林镇、杨巷镇、新建镇、和桥镇、高塍镇、万石镇、周铁镇、芳桥镇、丁蜀镇、湖父镇。