我正在使用Odoo Online并尝试安装我已构建的自定义模块。我安装了Base import module以允许在Odoo Online实例上安装自定义模块。使用基本导入模块为Odoo Online安装自定义模块
我然后创建由以下的单模:
mymodule/
__init__.py
__manifeset__.py
product.py
views/
product_product_tree.xml
这里是文件的内容:
__init__.py
__manifest__.py
个{
'name': "My Module",
'version': '1.0',
'depends': ['stock', 'sale', 'contacts', 'purchase'],
'description': """
Add custom functionality.
""",
# data files always loaded at installation
'data': [
'views/product_product_tree.xml',
],
}
product.py
from odoo import models, fields, api
class ProductProduct(models.Model):
_inherit = 'product.product'
x_reserved_qty = fields.Float(string='Reserved', readonly=True)
视图/ product_product_tree.xml
<odoo>
<data>
<record model="ir.ui.view" id="mymodule.product_product_tree">
<field name="name">x_product.product.tree</field>
<field name="model">product.product</field>
<field name="priority" eval="16"/>
<field name="inherit_id" ref="product.product_product_tree_view"/>
<field name="arch" type="xml">
<xpath expr="//tree" position="inside">
<field name="x_reserved_qty"/>
</xpath>
</field>
</record>
</data>
</odoo>
我然后拉上该文件,并经由基导入模块导入。这样做会导致错误并且模块不会安装。发生此错误的原因是模型中不存在x_reserved_qty
字段,即使我已在product.py
中定义它。看起来模块的python部分永远不会被执行。
我可以通过注释掉<field name="x_reserved_qty"/>
行来确认,然后重新导入模块。这次它成功导入,但是当我浏览到Settings > Technical > Database Structure > Fields
时,我没有看到我的新字段在任何地方列出。
有谁知道python文件是否支持通过此基本导入模块方法导入的自定义模块?该模块介绍说:
这个模块允许授权用户导入定制目的的自定义数据模块 (.xml文件和静态资产产生)。
它特别提到.xml和静态资产,但不是python文件。所以,我只是想知道如果我在我的python文件中做了错误,导致这不起作用,或者它实际上设计为不支持模块中的python文件。
有没有这个在线解决方案!或者我们一直为我们的客户购买服务器?并在本地网络中使用它 – Cherif