I am using Odoo Online and trying to install a custom module that I have built. I installed the Base import module to allow for installing custom modules on an Odoo Online instance.
I then created a simple module consisting of the following:
mymodule/
__init__.py
__manifeset__.py
product.py
views/
product_product_tree.xml
Here is the content of the files:
__init__.py
from . import product
__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)
views/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>
I then zip up the file and import it via the Base Import Module. Doing so results in an error and the module does not install. The error is occurring because the x_reserved_qty
field does not exist on the model even though I have defined it in product.py
. It seems that the python portion of the module is never getting executed.
I can confirm this by commenting out the <field name="x_reserved_qty"/>
line, and reimporting the module. This time it imports successfully, but when I browse to Settings > Technical > Database Structure > Fields
, I do not see my new field listed anywhere.
Does anybody know if python files are supported for custom modules imported via this Base Import Module method? The module description says:
This module allows authorized users to import a custom data module (.xml files and static assests) for customization purpose.
It specifically mentions .xml and static assets, but not python files. So, I'm just wondering if I'm doing something wrong in my python files that is causing this not to work, or if it's actually designed not to support python files in modules.