Just recently I've found that prototype inheritance in Odoo ORM also work with non-abstract parent class as witness in "ir.actions.*" and "event.booth". However, I've found it works differently between these two usages.
In "ir.actions.*", whenever we create the descendant record, like "ir.actions.report", the matching record in its parent -- "ir.actions.actions" -- will be created automatically.
class IrActionsReport(models.Model):
_name = 'ir.actions.report'
_description = 'Report Action'
_inherit = ['ir.actions.actions']
_table = 'ir_act_report_xml'
_order = 'name, id'
_allow_sudo_commands = False
But in "event.booth" the record in its parent -- "event.type.booth" -- won't be created.
class EventBooth(models.Model):
_name = 'event.booth'
_description = 'Event Booth'
_inherit = [
'event.type.booth',
'mail.thread',
'mail.activity.mixin'
]
I'm curious what make the behavior different in these two examples ? Why it work differently ? I could not spot any differences in the source code betwen them.
Ok I just solve the mystery myself by debugging Odoo code :)
Turns out automatic creation of parent class record is never a part of the features provided by Odoo ORM. The behavior of ir_actions and its children come from special case provided by PostgreSQL Inheritance feature which was enabled by custom DDL specified in Odoo base/data/base_data.sql
CREATE TABLE ir_actions (
id serial,
primary key(id)
);
CREATE TABLE ir_act_window (primary key(id)) INHERITS (ir_actions);
CREATE TABLE ir_act_report_xml (primary key(id)) INHERITS (ir_actions);
CREATE TABLE ir_act_url (primary key(id)) INHERITS (ir_actions);
CREATE TABLE ir_act_server (primary key(id)) INHERITS (ir_actions);
CREATE TABLE ir_act_client (primary key(id)) INHERITS (ir_actions);
So, basically, the "ir_actions.*" is the special case, not a typical Odoo ORM feature