Search code examples
crashodoosql-insertodoo-11

Odoo 11: Cant update module because new template was added to the module


I am fairly new to Odoo and I wanted to toy around on a test module for which I have created a few views (templates) for the web pages. At first, when there was only one template, everything was working fine, but when I tried adding another, the updates suddenly wouldn't work anymore. You'll find below the code of the first and the second template plus the error message as-well as my manifest file

First template

<?xml version="1.0" encoding="utf-8"?>
<odoo>

    <template id="template_test_hello_world" name="Test Hello World">&lt;!DOCTYPE html&gt;
        <html>

            <body>
                <div id="test_hello_world_page_text">
                    <p>Url text: <t t-esc="val"/></p>
                </div>
                <div>
                    <t t-foreach="models" t-as="model">
                        <p><t t-esc="model.id"/><t t-esc="model.preview_name"/></p>
                    </t>
                </div>

            </body>

        </html>
    </template>

</odoo>

Second Template

<?xml version="1.0" encoding="utf-8"?>
<odoo>

    <template id="template_random" name="Test Random">&lt;!DOCTYPE html&gt;
        <html>

            <body>
                <div id="test_random_div">
                    <p>BlaBlaBla</p>
                </div>

            </body>

        </html>
    </template>

</odoo>

The manifest

{
    'name': "Tests",
    'summary': """
        Testing stuff
    """,
    'description': """
        Yes. 
    """,
    'author': "",
    'website': "",
    'category': 'Uncategorized',
    'version': '0.1',
    'depends': [],
    'data': [
        'views/test_hello_world_template.xml',
        'data/test_models.xml',
        'security/ir.model.access.csv',
        'views/random_template.xml',
    ],
    "installable": True,
}

The Error message

2020-02-07 11:21:47,945 27164 ERROR smthg odoo.sql_db: bad query: b'INSERT INTO "ir_ui_view" ("id", "key", "priority", "active", "type", "name", "mode", "create_uid", "write_uid", "create_date", "write_date") VALUES(nextval(\'ir_ui_view_id_seq\'), \'my_module.template_test_hello_world\', 16, true, \'qweb\', \'Test Hello World\', \'primary\', 1, 1, (now() at time zone \'UTC\'), (now() at time zone \'UTC\')) RETURNING id'
ERROR: null value in column "projection" violates not-null constraint
DETAIL:  Failing row contains (2531, 2020-02-07 11:21:47.854173, 1, 2020-02-07 11:21:47.854173, t, null, null, null, Test Hello World, null, 16, primary, null, qweb, 1, null, null, null, null, null, null, my_module.template_test_hello_world, null, null, null, null, null).

2020-02-07 11:21:47,946 27164 WARNING smthg odoo.modules.loading: Transient module states were reset
2020-02-07 11:21:48,044 27164 ERROR smthg odoo.modules.registry: Failed to load registry
Traceback (most recent call last):
  File "/etc/odoo/odoo-server/odoo/odoo/tools/convert.py", line 745, in parse
    self._tags[rec.tag](rec, de, mode=mode)
  File "/etc/odoo/odoo-server/odoo/odoo/tools/convert.py", line 723, in _tag_template
    return self._tag_record(record, data_node)
  File "/etc/odoo/odoo-server/odoo/odoo/tools/convert.py", line 655, in _tag_record
    id = self.env(context=rec_context)['ir.model.data']._update(rec_model, self.module, res, rec_id or False, not self.isnoupdate(data_node), noupdate=self.isnoupdate(data_node), mode=self.mode)
  File "/etc/odoo/odoo-server/odoo/odoo/addons/base/ir/ir_model.py", line 1504, in _update
    record = record.create(values)
  File "/etc/odoo/odoo-server/odoo/odoo/addons/base/ir/ir_ui_view.py", line 408, in create
    return super(View, self).create(self._compute_defaults(values))
  File "/etc/odoo/odoo-server/odoo/odoo/models.py", line 3409, in create
    record = self.browse(self._create(old_vals))
  File "/etc/odoo/odoo-server/odoo/odoo/models.py", line 3502, in _create
    cr.execute(query, tuple(u[2] for u in updates if len(u) > 2))
  File "/etc/odoo/odoo-server/odoo/odoo/sql_db.py", line 155, in wrapper
    return f(self, *args, **kwargs)
  File "/etc/odoo/odoo-server/odoo/odoo/sql_db.py", line 232, in execute
    res = self._obj.execute(query, params)
psycopg2.IntegrityError: null value in column "projection" violates not-null constraint
DETAIL:  Failing row contains (2531, 2020-02-07 11:21:47.854173, 1, 2020-02-07 11:21:47.854173, t, null, null, null, Test Hello World, null, 16, primary, null, qweb, 1, null, null, null, null, null, null, my_module.template_test_hello_world, null, null, null, null, null).


During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/etc/odoo/odoo-server/odoo/odoo/modules/registry.py", line 85, in new
    odoo.modules.load_modules(registry._db, force_demo, status, update_module)
  File "/etc/odoo/odoo-server/odoo/odoo/modules/loading.py", line 376, in load_modules
    force, status, report, loaded_modules, update_module, models_to_check)
  File "/etc/odoo/odoo-server/odoo/odoo/modules/loading.py", line 274, in load_marked_modules
    perform_checks=perform_checks, models_to_check=models_to_check
  File "/etc/odoo/odoo-server/odoo/odoo/modules/loading.py", line 181, in load_module_graph
    _load_data(cr, module_name, idref, mode, kind='data')
  File "/etc/odoo/odoo-server/odoo/odoo/modules/loading.py", line 95, in _load_data
    tools.convert_file(cr, module_name, filename, idref, mode, noupdate, kind, report)
  File "/etc/odoo/odoo-server/odoo/odoo/tools/convert.py", line 792, in convert_file
    convert_xml_import(cr, module, fp, idref, mode, noupdate, report)
  File "/etc/odoo/odoo-server/odoo/odoo/tools/convert.py", line 853, in convert_xml_import
    obj.parse(doc.getroot(), mode=mode)
  File "/etc/odoo/odoo-server/odoo/odoo/tools/convert.py", line 752, in parse
    exc_info[2]
  File "/etc/odoo/odoo-server/odoo/odoo/tools/pycompat.py", line 86, in reraise
    raise value.with_traceback(tb)
  File "/etc/odoo/odoo-server/odoo/odoo/tools/convert.py", line 745, in parse
    self._tags[rec.tag](rec, de, mode=mode)
  File "/etc/odoo/odoo-server/odoo/odoo/tools/convert.py", line 723, in _tag_template
    return self._tag_record(record, data_node)
  File "/etc/odoo/odoo-server/odoo/odoo/tools/convert.py", line 655, in _tag_record
    id = self.env(context=rec_context)['ir.model.data']._update(rec_model, self.module, res, rec_id or False, not self.isnoupdate(data_node), noupdate=self.isnoupdate(data_node), mode=self.mode)
  File "/etc/odoo/odoo-server/odoo/odoo/addons/base/ir/ir_model.py", line 1504, in _update
    record = record.create(values)
  File "/etc/odoo/odoo-server/odoo/odoo/addons/base/ir/ir_ui_view.py", line 408, in create
    return super(View, self).create(self._compute_defaults(values))
  File "/etc/odoo/odoo-server/odoo/odoo/models.py", line 3409, in create
    record = self.browse(self._create(old_vals))
  File "/etc/odoo/odoo-server/odoo/odoo/models.py", line 3502, in _create
    cr.execute(query, tuple(u[2] for u in updates if len(u) > 2))
  File "/etc/odoo/odoo-server/odoo/odoo/sql_db.py", line 155, in wrapper
    return f(self, *args, **kwargs)
  File "/etc/odoo/odoo-server/odoo/odoo/sql_db.py", line 232, in execute
    res = self._obj.execute(query, params)
odoo.tools.convert.ParseError: "null value in column "projection" violates not-null constraint
DETAIL:  Failing row contains (2531, 2020-02-07 11:21:47.854173, 1, 2020-02-07 11:21:47.854173, t, null, null, null, Test Hello World, null, 16, primary, null, qweb, 1, null, null, null, null, null, null, my_module.template_test_hello_world, null, null, null, null, null).
" while parsing None:4, near
<t name="Test Hello World" t-name="my_module.template_test_hello_world">&lt;!DOCTYPE html&gt;
            <html>

                <body>
                    <div id="test_hello_world_page_text">
                        <p>Url text: <t t-esc="val"/></p>
                    </div>
                    <div>
                        <t t-foreach="models" t-as="model">
                            <p><t t-esc="model.id"/><t t-esc="model.preview_name"/></p>
                        </t>
                    </div>

                </body>

            </html>
        </t>
2020-02-07 11:21:48,048 27164 CRITICAL smthg odoo.service.server: Failed to initialize database `smthg`.
Traceback (most recent call last):
  File "/etc/odoo/odoo-server/odoo/odoo/tools/convert.py", line 745, in parse
    self._tags[rec.tag](rec, de, mode=mode)
  File "/etc/odoo/odoo-server/odoo/odoo/tools/convert.py", line 723, in _tag_template
    return self._tag_record(record, data_node)
  File "/etc/odoo/odoo-server/odoo/odoo/tools/convert.py", line 655, in _tag_record
    id = self.env(context=rec_context)['ir.model.data']._update(rec_model, self.module, res, rec_id or False, not self.isnoupdate(data_node), noupdate=self.isnoupdate(data_node), mode=self.mode)
  File "/etc/odoo/odoo-server/odoo/odoo/addons/base/ir/ir_model.py", line 1504, in _update
    record = record.create(values)
  File "/etc/odoo/odoo-server/odoo/odoo/addons/base/ir/ir_ui_view.py", line 408, in create
    return super(View, self).create(self._compute_defaults(values))
  File "/etc/odoo/odoo-server/odoo/odoo/models.py", line 3409, in create
    record = self.browse(self._create(old_vals))
  File "/etc/odoo/odoo-server/odoo/odoo/models.py", line 3502, in _create
    cr.execute(query, tuple(u[2] for u in updates if len(u) > 2))
  File "/etc/odoo/odoo-server/odoo/odoo/sql_db.py", line 155, in wrapper
    return f(self, *args, **kwargs)
  File "/etc/odoo/odoo-server/odoo/odoo/sql_db.py", line 232, in execute
    res = self._obj.execute(query, params)
psycopg2.IntegrityError: null value in column "projection" violates not-null constraint
DETAIL:  Failing row contains (2531, 2020-02-07 11:21:47.854173, 1, 2020-02-07 11:21:47.854173, t, null, null, null, Test Hello World, null, 16, primary, null, qweb, 1, null, null, null, null, null, null, my_module.template_test_hello_world, null, null, null, null, null).


During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/etc/odoo/odoo-server/odoo/odoo/service/server.py", line 1006, in preload_registries
    registry = Registry.new(dbname, update_module=update_module)
  File "/etc/odoo/odoo-server/odoo/odoo/modules/registry.py", line 85, in new
    odoo.modules.load_modules(registry._db, force_demo, status, update_module)
  File "/etc/odoo/odoo-server/odoo/odoo/modules/loading.py", line 376, in load_modules
    force, status, report, loaded_modules, update_module, models_to_check)
  File "/etc/odoo/odoo-server/odoo/odoo/modules/loading.py", line 274, in load_marked_modules
    perform_checks=perform_checks, models_to_check=models_to_check
  File "/etc/odoo/odoo-server/odoo/odoo/modules/loading.py", line 181, in load_module_graph
    _load_data(cr, module_name, idref, mode, kind='data')
  File "/etc/odoo/odoo-server/odoo/odoo/modules/loading.py", line 95, in _load_data
    tools.convert_file(cr, module_name, filename, idref, mode, noupdate, kind, report)
  File "/etc/odoo/odoo-server/odoo/odoo/tools/convert.py", line 792, in convert_file
    convert_xml_import(cr, module, fp, idref, mode, noupdate, report)
  File "/etc/odoo/odoo-server/odoo/odoo/tools/convert.py", line 853, in convert_xml_import
    obj.parse(doc.getroot(), mode=mode)
  File "/etc/odoo/odoo-server/odoo/odoo/tools/convert.py", line 752, in parse
    exc_info[2]
  File "/etc/odoo/odoo-server/odoo/odoo/tools/pycompat.py", line 86, in reraise
    raise value.with_traceback(tb)
  File "/etc/odoo/odoo-server/odoo/odoo/tools/convert.py", line 745, in parse
    self._tags[rec.tag](rec, de, mode=mode)
  File "/etc/odoo/odoo-server/odoo/odoo/tools/convert.py", line 723, in _tag_template
    return self._tag_record(record, data_node)
  File "/etc/odoo/odoo-server/odoo/odoo/tools/convert.py", line 655, in _tag_record
    id = self.env(context=rec_context)['ir.model.data']._update(rec_model, self.module, res, rec_id or False, not self.isnoupdate(data_node), noupdate=self.isnoupdate(data_node), mode=self.mode)
  File "/etc/odoo/odoo-server/odoo/odoo/addons/base/ir/ir_model.py", line 1504, in _update
    record = record.create(values)
  File "/etc/odoo/odoo-server/odoo/odoo/addons/base/ir/ir_ui_view.py", line 408, in create
    return super(View, self).create(self._compute_defaults(values))
  File "/etc/odoo/odoo-server/odoo/odoo/models.py", line 3409, in create
    record = self.browse(self._create(old_vals))
  File "/etc/odoo/odoo-server/odoo/odoo/models.py", line 3502, in _create
    cr.execute(query, tuple(u[2] for u in updates if len(u) > 2))
  File "/etc/odoo/odoo-server/odoo/odoo/sql_db.py", line 155, in wrapper
    return f(self, *args, **kwargs)
  File "/etc/odoo/odoo-server/odoo/odoo/sql_db.py", line 232, in execute
    res = self._obj.execute(query, params)
odoo.tools.convert.ParseError: "null value in column "projection" violates not-null constraint
DETAIL:  Failing row contains (2531, 2020-02-07 11:21:47.854173, 1, 2020-02-07 11:21:47.854173, t, null, null, null, Test Hello World, null, 16, primary, null, qweb, 1, null, null, null, null, null, null, my_module.template_test_hello_world, null, null, null, null, null).
" while parsing None:4, near
<t name="Test Hello World" t-name="my_module.template_test_hello_world">&lt;!DOCTYPE html&gt;
            <html>

                <body>
                    <div id="test_hello_world_page_text">
                        <p>Url text: <t t-esc="val"/></p>
                    </div>
                    <div>
                        <t t-foreach="models" t-as="model">
                            <p><t t-esc="model.id"/><t t-esc="model.preview_name"/></p>
                        </t>
                    </div>

                </body>

            </html>
        </t>

The most interesting tho me probably is the first line:

bad query: b'INSERT INTO "ir_ui_view" ("id", "key", "priority", "active", "type", "name", "mode", "create_uid", "write_uid", "create_date", "write_date") VALUES(nextval(\'ir_ui_view_id_seq\'), \'my_module.template_test_hello_world\', 16, true, \'qweb\', \'Test Hello World\', \'primary\', 1, 1, (now() at time zone \'UTC\'), (now() at time zone \'UTC\')) RETURNING id'
ERROR: null value in column "projection" violates not-null constraint
DETAIL:  Failing row contains (2531, 2020-02-07 11:21:47.854173, 1, 2020-02-07 11:21:47.854173, t, null, null, null, Test Hello World, null, 16, primary, null, qweb, 1, null, null, null, null, null, null, my_module.template_test_hello_world, null, null, null, null, null).

But I don't know much about SQL or Odoo yet and I have found very little on the web although I spent almost an entire day on this, also, as you can see at the bottom of the error there seems to be a problem with the first template maybe it'll be useful for you to know that at some point it was the second template that was being displayed there.

I guess in the end my question is, does anyone know what is happening and how I can solve this?


Solution

  • For anyone facing the same issue, the problem seems to be caused by a corrupted view. A complete update of the system forces Odoo to recreate every view so that works. That means update all your packages by specifying all as the package name in the update command:

    odoo-bin -d db -c config -u all