python - 在 View 级别创建 odoo 模型

标签 python odoo

我们可以在 odoo 中创建一个模型,这样它就不会反射(reflect)在数据库级别吗?

例如:

class SalaOrder(model.models):
    _name='sale.order'

我不想在数据库中创建“sale_order”表。

最佳答案

根据models.py(odoo/odoo/models.py)上的注释,您可以将_auto设置为False

class SalaOrder(model.models):
    _name = 'sale.order'
    _auto = False

评论说

_auto = False # don't create any database backend

以下是有关 Odoo 模型的更多详细信息(来自同一代码):

Odoo models are created by inheriting:

  • :class:Model for regular database-persisted models

  • :class:TransientModel for temporary data, stored in the database but automatically vacuumed every so often

  • :class:AbstractModel for abstract super classes meant to be shared by multiple inheriting models

The system automatically instantiates every model once per database. Those instances represent the available models on each database, and depend on which modules are installed on that database. The actual class of each instance is built from the Python classes that create and inherit from the corresponding model.

Every model instance is a "recordset", i.e., an ordered collection of records of the model. Recordsets are returned by methods like :meth:~.browse, :meth:~.search, or field accesses. Records have no explicit representation: a record is represented as a recordset of one record.

To create a class that should not be instantiated, the _register class attribute may be set to False.

关于python - 在 View 级别创建 odoo 模型,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47886193/

相关文章:

python - 使用 mpi4py 并行化函数调用

Python Tkinter - 属性错误 : 'str' object has no attribute 'read'

python - 如何将域名应用于按钮?

treeview - 如何限制/禁用表单 View ,同时单击 Odoo 中 one2many 字段的 TreeView

python - 在rml报告中设置两种语言

python - 使用 gnuplot 在一条曲线中绘制多个 (x,y) 坐标

python - 从 TF-IDF 到 spark、pyspark 中的 LDA 聚类

python - Odoo - 为特定用户隐藏按钮

python - 奥杜 8 : How can I send context to python method?

python - 计算以每个数据点为中心的固定半径球内数据点数的有效方法