Reputation: 393
I was walking through the documentation of odoo11(https://www.odoo.com/documentation/11.0/howtos/backend.html#inheritance), but I got stuck in in the Inheritance
portion as I followed each steps carefully and confirmed several times buts its the same and I'm not able to run my modules.
partner.py
# -*- coding: utf-8 -*-
from odoo import fields, models
class Partner(models.Model):
_inherit = 'res.partner'
# Add a new coumn to res.partner model, by default parameters are not instructors.
instructor = fields.Boolean("Instructor", default='False')
session_ids = fields.Many2many('openacademy.session',
string="Attended Sessions",
readonly=True)
partner.xml
<?xml version="1.0" encoding="UTF-8"?>
<odoo>
<!-- Add instructor field to existing view. -->
<record model="ir.ui.view" id="partner_instructor_form_view">
<field name="name">partner.instructor</field>
<field name="model">res.partner</field>
<field name="inherit_id" ref="base.view_partner_form"/>
<field name="arch" type="xml">
<notebook position="inside">
<page string="Sessions">
<group>
<field name="instructor"/>
<field name="session_ids"/>
</group>
</page>
</notebook>
</field>
</record>
<record model="ir.actions.act_window" id="contact_list_action">
<field name="name">Contacts</field>
<field name="model">res.partner</field>
<field name="view_type">form</field>
<field name="view_mode">tree,form</field>
</record>
<menuitem id="configuration_menu" name="Configuration" parent="main_openacademy_menu"/>
<menuitem id="contact_menu" name="Contacts" parent="configuration_menu" action="contact_list_action"/>
</odoo>
Also I have added these file names in __init__.py as well as __manifest__.py respectively.
Error message
2018-10-08 06:11:56,242 14284 WARNING odoo11 odoo.models: ir.actions.act_window.create() includes unknown fields: model
2018-10-08 06:11:56,243 14284 ERROR odoo11 odoo.sql_db: bad query: b'INSERT INTO "ir_act_window" ("id", "binding_type", "type", "context", "auto_search", "limit", "target", "name", "view_type", "view_mode", "filter", "multi", "create_uid", "write_uid", "create_date", "write_date") VALUES(nextval(\'ir_actions_id_seq\'), \'action\', \'ir.actions.act_window\', \'{}\', true, 80, \'current\', \'Contacts\', \'form\', \'form\', false, false, 1, 1, (now() at time zone \'UTC\'), (now() at time zone \'UTC\')) RETURNING id'
ERROR: null value in column "res_model" violates not-null constraint
DETAIL: Failing row contains (297, Contacts, ir.actions.act_window, null, null, action, 1, 2018-10-08 06:11:56.093253, 1, 2018-10-08 06:11:56.093253, null, null, {}, null, null, null, current, form, form, null, 80, null, f, t, f).
2018-10-08 06:11:56,244 14284 WARNING odoo11 odoo.modules.loading: Transient module states were reset
2018-10-08 06:11:56,245 14284 ERROR odoo11 odoo.modules.registry: Failed to load registry
Traceback (most recent call last):
File "/odoo/odoo-server/odoo/modules/registry.py", line 59, in __new__
return cls.registries[db_name]
File "/odoo/odoo-server/odoo/tools/func.py", line 68, in wrapper
return func(self, *args, **kwargs)
File "/odoo/odoo-server/odoo/tools/lru.py", line 44, in __getitem__
a = self.d[obj].me
KeyError: 'odoo11'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/odoo/odoo-server/odoo/tools/convert.py", line 744, in parse
self._tags[rec.tag](rec, de, mode=mode)
File "/odoo/odoo-server/odoo/tools/convert.py", line 654, 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 "/odoo/odoo-server/odoo/addons/base/ir/ir_model.py", line 1487, in _update
record = record.create(values)
File "/odoo/odoo-server/odoo/addons/base/ir/ir_actions.py", line 230, in create
return super(IrActionsActWindow, self).create(vals)
File "/odoo/odoo-server/odoo/addons/base/ir/ir_actions.py", line 57, in create
res = super(IrActions, self).create(vals)
File "/odoo/odoo-server/odoo/models.py", line 3372, in create
record = self.browse(self._create(old_vals))
File "/odoo/odoo-server/odoo/models.py", line 3465, in _create
cr.execute(query, tuple(u[2] for u in updates if len(u) > 2))
File "/odoo/odoo-server/odoo/sql_db.py", line 155, in wrapper
return f(self, *args, **kwargs)
File "/odoo/odoo-server/odoo/sql_db.py", line 232, in execute
res = self._obj.execute(query, params)
psycopg2.IntegrityError: null value in column "res_model" violates not-null constraint
DETAIL: Failing row contains (297, Contacts, ir.actions.act_window, null, null, action, 1, 2018-10-08 06:11:56.093253, 1, 2018-10-08 06:11:56.093253, null, null, {}, null, null, null, current, form, form, null, 80, null, f, t, f).
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/odoo/odoo-server/odoo/modules/registry.py", line 85, in new
odoo.modules.load_modules(registry._db, force_demo, status, update_module)
File "/odoo/odoo-server/odoo/modules/loading.py", line 376, in load_modules
force, status, report, loaded_modules, update_module, models_to_check)
File "/odoo/odoo-server/odoo/modules/loading.py", line 274, in load_marked_modules
perform_checks=perform_checks, models_to_check=models_to_check
File "/odoo/odoo-server/odoo/modules/loading.py", line 181, in load_module_graph
_load_data(cr, module_name, idref, mode, kind='data')
File "/odoo/odoo-server/odoo/modules/loading.py", line 95, in _load_data
tools.convert_file(cr, module_name, filename, idref, mode, noupdate, kind, report)
File "/odoo/odoo-server/odoo/tools/convert.py", line 791, in convert_file
convert_xml_import(cr, module, fp, idref, mode, noupdate, report)
File "/odoo/odoo-server/odoo/tools/convert.py", line 852, in convert_xml_import
obj.parse(doc.getroot(), mode=mode)
File "/odoo/odoo-server/odoo/tools/convert.py", line 751, in parse
exc_info[2]
File "/odoo/odoo-server/odoo/tools/pycompat.py", line 86, in reraise
raise value.with_traceback(tb)
File "/odoo/odoo-server/odoo/tools/convert.py", line 744, in parse
self._tags[rec.tag](rec, de, mode=mode)
File "/odoo/odoo-server/odoo/tools/convert.py", line 654, 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 "/odoo/odoo-server/odoo/addons/base/ir/ir_model.py", line 1487, in _update
record = record.create(values)
File "/odoo/odoo-server/odoo/addons/base/ir/ir_actions.py", line 230, in create
return super(IrActionsActWindow, self).create(vals)
File "/odoo/odoo-server/odoo/addons/base/ir/ir_actions.py", line 57, in create
res = super(IrActions, self).create(vals)
File "/odoo/odoo-server/odoo/models.py", line 3372, in create
record = self.browse(self._create(old_vals))
File "/odoo/odoo-server/odoo/models.py", line 3465, in _create
cr.execute(query, tuple(u[2] for u in updates if len(u) > 2))
File "/odoo/odoo-server/odoo/sql_db.py", line 155, in wrapper
return f(self, *args, **kwargs)
File "/odoo/odoo-server/odoo/sql_db.py", line 232, in execute
res = self._obj.execute(query, params)
odoo.tools.convert.ParseError: "null value in column "res_model" violates not-null constraint
DETAIL: Failing row contains (297, Contacts, ir.actions.act_window, null, null, action, 1, 2018-10-08 06:11:56.093253, 1, 2018-10-08 06:11:56.093253, null, null, {}, null, null, null, current, form, form, null, 80, null, f, t, f).
" while parsing /odoo/odoo-server/custom_addons/openacademy/views/partner.xml:21, near
<record model="ir.actions.act_window" id="contact_list_action">
<field name="name">Contacts</field>
<field name="model">res.partner</field>
<field name="view_type">form</field>
<field name="view_mode">form</field>
</record>
I have not made any changes, these code is from the documentation itself.
Please help me out. Quick help is really appreciated and thanks in advance.
Please let me know if anyone needs more detail.
Upvotes: 1
Views: 2332
Reputation: 3610
In partner.xml you have a field named "model" in your action. You should use "res_model" field in it. The source on the documentation page is correct. Please correct in your code the act_window specification model -> res_model:
...
<record model="ir.actions.act_window" id="contact_list_action">
<field name="name">Contacts</field>
<field name="res_model">res.partner</field>
...
Upvotes: 2