Odoo - server error when adding field to inherited module

146 Views Asked by At

EDIT: An user shared a related questions that seems to be spot-on, but I have a problem executing that solution: I can't start from command-line because I am using Odoo.sh. If someone knows how to resolve this problem specifically on Odoo.sh I would greatly appreciate it!

I have added fields to inherited classes before, but for some reason this time it is causing an internal server error (I am using Odoo.sh, and get error 500 when I try to launch the build in staging branch).

In the code below I am trying to add compid2 as a company ID that will match the company ID from a previous database, for continuity of data.

When I comment out the line in the .py that has compid2 then I no longer get the server error (obviously the code does not produce what I want then, though). The xml code does not cause a server error. I even have other fields declared in the .py file that are working just fine! The ones that work are type Many2Many and Integer. It is just this Char field that is causing an error.

My code looks exactly like many solutions here on stackoverflow and in tutorials, but it still is not working.

python code

from odoo import models, fields

class ResPartner(models.Model):
    _inherit = 'res.partner'

    compid2 = fields.Char(string='Company ID')

xml code

<?xml version="1.0" encoding="utf-8"?>
<odoo>
    <record id="res_partner_form_view_inherit" model="ir.ui.view">
        <field name="name">res.partner.form.view.inherit</field>
        <field name="model">res.partner</field>
        <field name="inherit_id" ref="base.view_partner_form"/>
        <field name="arch" type="xml">
            <field name="vat" position="after">
                <field name="compid2"/>
            </field>
        </field>
    </record>

</odoo>
1

There are 1 best solutions below

2
On

The thing could be that you are adding a field to res.partner and that model like res.users and res.company it's very tied to the Odoo startup so the updates needs to happens using commandline args like -u your_module_name

The weird thing it's that probably that's what Odoo.sh it's doing to update the modules but who knows.

Try to run the update of your module using the commandline