0

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 Answers1

1

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

aekis.dev
  • 2,626
  • 1
  • 12
  • 19
  • Interesting, I didn't know res.partner has a special status.I can't even get to the point of trying to update the module, server error happens when I try to open the environment at all. Usually this only happens when I have syntax errors making invalid code. – Harebrained Aug 10 '23 at 14:13
  • The thing it's that `res.partner` and `res.users` have part of the Odoo startup process, so queries generated using those models will endup trying to use fields that doesn't exists in the database. That's why you get those errors and not even able to get into the modules to update – aekis.dev Aug 10 '23 at 14:27