Files
odoo_source/addons/mail/static/tests/models/test_models.js
T
Sébastien Theys 60c87dd426 [IMP] mail, *: introduce identifyingMode and remove identifyingFields
* = calendar, hr, im_livechat, rating, snailmail, website_livechat

This simplifies definition and overrides and opens up new identification
opportunities.

Part of task-2741982

closes odoo/odoo#98166

Related: odoo/enterprise#30470
Signed-off-by: Louis Wicket (wil) <wil@odoo.com>
2022-08-17 11:21:40 +02:00

76 lines
1.7 KiB
JavaScript

/** @odoo-module **/
import { registerModel } from '@mail/model/model_core';
import { attr, many, one } from '@mail/model/model_field';
import { insertAndReplace } from '@mail/model/model_field_command';
registerModel({
name: 'TestAddress',
fields: {
id: attr({
identifying: true,
readonly: true,
required: true,
}),
addressInfo: attr(),
contact: one('TestContact', {
inverse: 'address',
}),
},
});
registerModel({
name: 'TestContact',
fields: {
id: attr({
identifying: true,
readonly: true,
required: true,
}),
address: one('TestAddress', {
inverse: 'contact',
}),
favorite: one('TestHobby', {
default: insertAndReplace({ description: 'football' }),
}),
hobbies: many('TestHobby', {
default: insertAndReplace([
{ description: 'hiking' },
{ description: 'fishing' },
]),
}),
tasks: many('TestTask', {
inverse: 'responsible'
}),
},
});
registerModel({
name: 'TestHobby',
fields: {
description: attr({
identifying: true,
readonly: true,
required: true,
}),
},
});
registerModel({
name: 'TestTask',
fields: {
id: attr({
identifying: true,
readonly: true,
required: true,
}),
title: attr(),
difficulty: attr({
default: 1,
}),
responsible: one('TestContact', {
inverse: 'tasks'
}),
},
});