宜兴通达竭诚为您服务。

通达科技 - 宜兴电脑维护及IT服务外包服务商

Model Attributes
  • 上传者: 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 w ......
正文 相关文章 请喝咖啡

    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

    这些是在创建新模型或使用现有模型时定义的特征。让我们看看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.

    _auto = false - 无论我们是否创建设置为False的新数据库表,都要重写init()来创建数据库表。对于模型和瞬态模型,它自动默认为True,对于抽象模型,它默认为False。

    _log_access - Whether the ORM should automatically generate and update the Access Log Files. Defaults to whatever value was set for _auto.

    _log_access - ORM是否应自动生成和更新访问日志文件。默认为_auto设置的任何值。

    _table = None - if _auto, it is the SQL table name used by the model.

    _table = None - 如果_auto,则是模型使用的SQL表名。

    _sequence = None - SQL sequence, which is used for an ID field.

    _sequence = None - SQL序列,用于ID字段。

    _sql_constraints = [] - SQL constraints [(name, sql_def, message)].

    _sql_constraints = [] - SQL约束[(名称、SQL_def、消息)]。

    _register = False - registry visibility by default is false.

    _register = False -默认情况下,注册表可见性为false。

    _abstract = True - To check whether the model is an abstract model.

    _abstract = True - 检查模型是否为抽象模型。

    _transient = True - To check whether the model is a Transient model.

    _transient = True - 检查模型是否为瞬态模型。

    _name = None - the name of the model.

    _name = None - 模型的名称。

    _inherit = () - we use the inherited attribute when we want to use a model that is already in the database.

    _inherit = () - 当我们想使用数据库中已有的模型时,我们使用继承的属性。

    _description = None - informal name of the models.

    _description = None - 模型的非正式名称。

    _inherits = {} - dictionary {‘parent_model’: ‘m2o_field’} mapping the _name of the parent objects to the names of the corresponding foreign key fields to use.

    _inherits = {} - 字典{父模型:m2ofield}将父对象的名称映射到要使用的相应外键字段的名称。

    _rec_name = None - used for labeling records. By default, it is the name of the record.

    _rec_name = None - 用于标记记录。默认情况下,它是记录的名称。

    _order = ‘id’ - Default order field for searching results.

    _order = ‘id’ -搜索结果的默认顺序字段。

    _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.

    _check_company_auto = False - 在写入和创建时,调用_check_company以确保公司在具有check_company=True属性的关系字段上的一致性。

    _parent_name = ‘parent_id’ - The many2one field used as parent field

    _parent_name = ‘parent_id’ - many2one字段用作父字段

    _parent_store = false - Set to True to compute parent_path field.

    _parent_store = false - 设置为True以计算parent_path字段。

    _date_name = ‘Date’ - used for default calendar view.

    _date_name = ‘Date’ - 用于默认日历视图。

    _fold_name = ‘fold’ - used to determine folded groups in kanban views.

    _fold_name = ‘fold’ -用于确定看板视图中的折叠组。

    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.

    Odoo中,它是为模块创建骨架结构的过程。我们可以使用Odoo脚手架自动设计模块结构。它节省了很多时间。模块通常是模块目录中的一个目录。插件路径指定模块路径。让我们看看如何做到这一点。为此,首先,让我们在/opt/odoo/custom插件下构建一个新模块,例如自定义插件。为了创建模块结构,首先,我们必须使用终端访问Odoo bin位置。

    输入scaffold命令以创建示例模块结构。命令如下。

    ./odoo-bin scaffold module_name folder_name

    module_name: Name of the module

    module_name:模块名称

    folder_name: Directory name inside which you want to create the module.

    folder_name: 要在其中创建模块的目录名称。

    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:

    通常,在模块目录中,模块是一个目录。插件路径指定模块路径。首先,在/opt/odoo/custom插件中创建一个新模块,例如自定义插件。为了创建模块结构,我们必须首先使用终端访问odoo-bin位置。为了自动生成模块结构,请运行以下命令:

    ./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.

    每个模块包含两个必需的python文件,即“__init__.py”和“__manifest__.py”文件。

    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.

    1.模块中包含的python文件是模型。

    2. Views are the XML files that help to display the records.

    2. 视图是帮助显示记录的XML文件。

    3. Data consists of demo data that are needed in the module. It contains XML that creates/updates databases.

    3.数据由模块中所需的演示数据组成。它包含创建/更新数据库的XML。

    4. The security file consists of configured files of access rights.

    4.安全文件由配置的访问权限文件组成。

    5. The __init__.py file imports all the python files defined in the module.

    5.__init__.py文件导入模块中定义的所有python文件。

    6. We use controllers when we need to render data to the website.

    6.当我们需要向网站呈现数据时,我们使用控制器。

    本文章从网上收集,如有侵权请联系tderp@tderp.com删除
  • 微信扫一扫,一分也是爱:
  • 微信

服务原则及地区范围

宜兴通达网络科技有限公司,地处中国宜兴环科园内,是一家高新技术企业。公司在企业网络维护和企业信息化建设与咨询方面,有10多年经验。

我公司愿与客户一道,力求彻底解决客户问题!
我们不是在给企业提供“头痛医头、脚痛医脚”的暂时解决方案,而是在部署根本性安全与稳定服务!!
我们愿携手客户,建立企业IT规划;杜绝随意安装系统、软件等操作;力求共同维护有序、安全、稳定的网络办公环境!!!
IT服务,服务是根本,客户是上帝;我们提供快速响应、快速上门、快速排查,提供优质高效的服务!!!!

通达科技提供全国范围内的服务,服务形式包括远程协助、电话咨询、电子邮件咨询、传真咨询、问答平台的问题解决等。

宜兴地区提供上门服务:

  • 市区服务:宜城街道、城北街道(屺亭街道)、新街街道、新庄街道、环科园、渚桥开发区
  • 市郊服务:张渚镇、西渚镇、太华镇、徐舍镇、官林镇、杨巷镇、新建镇、和桥镇、高塍镇、万石镇、周铁镇、芳桥镇、丁蜀镇、湖父镇。
  • 联系电话:189-21-343434
  • 在线沟通: