[IMP] mail, *: avoid repetition in inverse relation type (js)

* = hr, im_livechat, website_livechat

task-2741386

closes odoo/odoo#83059

Related: odoo/enterprise#23616
Signed-off-by: Alexandre Kühn (aku) <aku@odoo.com>
This commit is contained in:
Sébastien Theys
2022-01-20 13:29:04 +00:00
parent c899bfcd84
commit 611046040b
87 changed files with 483 additions and 531 deletions
@@ -1,7 +1,7 @@
/** @odoo-module **/
import { registerModel } from '@mail/model/model_core';
import { attr, one2one } from '@mail/model/model_field';
import { attr, one } from '@mail/model/model_field';
import { insert, unlink } from '@mail/model/model_field_command';
registerModel({
@@ -161,14 +161,14 @@ registerModel({
/**
* Partner related to this employee.
*/
partner: one2one('Partner', {
partner: one('Partner', {
inverse: 'employee',
related: 'user.partner',
}),
/**
* User related to this employee.
*/
user: one2one('User', {
user: one('User', {
inverse: 'employee',
}),
},
@@ -1,7 +1,7 @@
/** @odoo-module **/
import { addFields, addRecordMethods, patchRecordMethods } from '@mail/model/model_core';
import { attr, one2one } from '@mail/model/model_field';
import { attr, one } from '@mail/model/model_field';
// ensure that the model definition is loaded before the patch
import '@mail/models/partner/partner';
@@ -45,7 +45,7 @@ addFields('Partner', {
* Employee related to this partner. It is computed through
* the inverse relation and should be considered read-only.
*/
employee: one2one('Employee', {
employee: one('Employee', {
inverse: 'partner',
}),
/**
+2 -2
View File
@@ -1,7 +1,7 @@
/** @odoo-module **/
import { addFields } from '@mail/model/model_core';
import { one2one } from '@mail/model/model_field';
import { one } from '@mail/model/model_field';
// ensure that the model definition is loaded before the patch
import '@mail/models/user/user';
@@ -9,7 +9,7 @@ addFields('User', {
/**
* Employee related to this user.
*/
employee: one2one('Employee', {
employee: one('Employee', {
inverse: 'user',
}),
});
@@ -1,7 +1,7 @@
/** @odoo-module **/
import { addFields, patchRecordMethods } from '@mail/model/model_core';
import { one2one } from '@mail/model/model_field';
import { one } from '@mail/model/model_field';
// ensure that the model definition is loaded before the patch
import '@mail/models/discuss/discuss';
@@ -21,7 +21,7 @@ addFields('Discuss', {
/**
* Discuss sidebar category for `livechat` channel threads.
*/
categoryLivechat: one2one('DiscussSidebarCategory', {
categoryLivechat: one('DiscussSidebarCategory', {
inverse: 'discussAsLivechat',
isCausal: true,
}),
@@ -1,12 +1,12 @@
/** @odoo-module **/
import { addFields, patchIdentifyingFields } from '@mail/model/model_core';
import { one2one } from '@mail/model/model_field';
import { one } from '@mail/model/model_field';
// ensure that the model definition is loaded before the patch
import '@mail/models/discuss_sidebar_category/discuss_sidebar_category';
addFields('DiscussSidebarCategory', {
discussAsLivechat: one2one('Discuss', {
discussAsLivechat: one('Discuss', {
inverse: 'categoryLivechat',
readonly: true,
}),
@@ -1,7 +1,7 @@
/** @odoo-module **/
import { addFields } from '@mail/model/model_core';
import { one2many } from '@mail/model/model_field';
import { many } from '@mail/model/model_field';
// ensure that the model definition is loaded before the patch
import '@mail/models/messaging/messaging';
@@ -9,7 +9,7 @@ addFields('Messaging', {
/**
* All pinned livechats that are known.
*/
pinnedLivechats: one2many('Thread', {
pinnedLivechats: many('Thread', {
inverse: 'messagingAsPinnedLivechat',
readonly: true,
}),
@@ -1,7 +1,7 @@
/** @odoo-module **/
import { addFields, addRecordMethods, patchModelMethods, patchRecordMethods } from '@mail/model/model_core';
import { many2one } from '@mail/model/model_field';
import { one } from '@mail/model/model_field';
import { clear, insert, link, replace, unlink } from '@mail/model/model_field_command';
// ensure that the model definition is loaded before the patch
import '@mail/models/thread/thread';
@@ -10,7 +10,7 @@ addFields('Thread', {
/**
* If set, current thread is a livechat.
*/
messagingAsPinnedLivechat: many2one('Messaging', {
messagingAsPinnedLivechat: one('Messaging', {
compute: '_computeMessagingAsPinnedLivechat',
inverse: 'pinnedLivechats',
}),
+18 -46
View File
@@ -87,8 +87,7 @@ export class ModelField {
/**
* This prop only makes sense in a relational field. Determine which
* type of relation there is between current record and other records.
* 4 types of relation are supported: 'one2one', 'one2many', 'many2one'
* and 'many2many'.
* 2 types of relation are supported: 'many', 'one'.
*/
this.relationType = relationType;
/**
@@ -146,47 +145,25 @@ export class ModelField {
}
/**
* Define a many2many field.
* Define a many field.
*
* @param {string} modelName
* @param {Object} [options]
* @returns {Object}
*/
static many2many(modelName, options) {
return ModelField._relation(modelName, Object.assign({}, options, { relationType: 'many2many' }));
static many(modelName, options) {
return ModelField._relation(modelName, Object.assign({}, options, { relationType: 'many' }));
}
/**
* Define a many2one field.
* Define a one field.
*
* @param {string} modelName
* @param {Object} [options]
* @returns {Object}
*/
static many2one(modelName, options) {
return ModelField._relation(modelName, Object.assign({}, options, { relationType: 'many2one' }));
}
/**
* Define a one2many field.
*
* @param {string} modelName
* @param {Object} [options]
* @returns {Object}
*/
static one2many(modelName, options) {
return ModelField._relation(modelName, Object.assign({}, options, { relationType: 'one2many' }));
}
/**
* Define a one2one field.
*
* @param {string} modelName
* @param {Object} [options]
* @returns {Object}
*/
static one2one(modelName, options) {
return ModelField._relation(modelName, Object.assign({}, options, { relationType: 'one2one' }));
static one(modelName, options) {
return ModelField._relation(modelName, Object.assign({}, options, { relationType: 'one' }));
}
/**
@@ -226,7 +203,7 @@ export class ModelField {
const [relationName, relatedFieldName] = this.related.split('.');
const Model = record.constructor;
const relationField = Model.__fieldMap[relationName];
if (['one2many', 'many2many'].includes(relationField.relationType)) {
if (relationField.relationType === 'many') {
const newVal = [];
for (const otherRecord of record[relationName]) {
const otherValue = otherRecord[relatedFieldName];
@@ -302,7 +279,7 @@ export class ModelField {
return this.read(record);
}
if (this.fieldType === 'relation') {
if (['one2one', 'many2one'].includes(this.relationType)) {
if (this.relationType === 'one') {
return this.read(record);
}
return [...this.read(record)];
@@ -486,11 +463,12 @@ export class ModelField {
*/
_insertOtherRecord(record, data) {
const OtherModel = record.models[this.to];
const otherField = OtherModel.__fieldMap[this.inverse];
const isMulti = typeof data[Symbol.iterator] === 'function';
const dataList = [];
for (const recordData of (isMulti ? data : [data])) {
const recordData2 = { ...recordData };
if (['one2one', 'one2many'].includes(this.relationType)) {
if (otherField.relationType === 'one') {
recordData2[this.inverse] = replace(record);
} else {
recordData2[this.inverse] = link(record);
@@ -577,11 +555,9 @@ export class ModelField {
*/
_setRelationLink(record, newValue, options) {
switch (this.relationType) {
case 'many2many':
case 'one2many':
case 'many':
return this._setRelationLinkX2Many(record, newValue, options);
case 'many2one':
case 'one2one':
case 'one':
return this._setRelationLinkX2One(record, newValue, options);
}
}
@@ -672,7 +648,7 @@ export class ModelField {
* @returns {boolean} whether the value changed for the current field
*/
_setRelationReplace(record, newValue, options) {
if (['one2one', 'many2one'].includes(this.relationType)) {
if (this.relationType === 'one') {
// for x2one replace is just link
return this._setRelationLinkX2One(record, newValue, options);
}
@@ -738,11 +714,9 @@ export class ModelField {
*/
_setRelationUnlink(record, newValue, options) {
switch (this.relationType) {
case 'many2many':
case 'one2many':
case 'many':
return this._setRelationUnlinkX2Many(record, newValue, options);
case 'many2one':
case 'one2one':
case 'one':
return this._setRelationUnlinkX2One(record, options);
}
}
@@ -867,7 +841,5 @@ export class ModelField {
}
export const attr = ModelField.attr;
export const many2many = ModelField.many2many;
export const many2one = ModelField.many2one;
export const one2many = ModelField.one2many;
export const one2one = ModelField.one2one;
export const many = ModelField.many;
export const one = ModelField.one;
+9 -29
View File
@@ -517,14 +517,11 @@ export class ModelManager {
if (!this.models[field.to]) {
throw new Error(`Relational field(${fieldName}) on ${Model} targets to unknown model name "${field.to}".`);
}
if (field.isCausal && !(['one2many', 'one2one'].includes(field.relationType))) {
throw new Error(`Relational field(${fieldName}) on ${Model} has "isCausal" true with a relation of type "${field.relationType}" but "isCausal" is only supported for "one2many" and "one2one".`);
if (field.required && field.relationType !== 'one') {
throw new Error(`Relational field(${fieldName}) on ${Model} has "required" true with a relation of type "${field.relationType}" but "required" is only supported for "one".`);
}
if (field.required && !(['one2one', 'many2one'].includes(field.relationType))) {
throw new Error(`Relational field(${fieldName}) on ${Model} has "required" true with a relation of type "${field.relationType}" but "required" is only supported for "one2one" and "many2one".`);
}
if (field.sort && !(['one2many', 'many2many'].includes(field.relationType))) {
throw new Error(`Relational field "${Model}/${fieldName}" has "sort" with a relation of type "${field.relationType}" but "sort" is only supported for "one2many" and "many2many".`);
if (field.sort && field.relationType !== 'many') {
throw new Error(`Relational field "${Model}/${fieldName}" has "sort" with a relation of type "${field.relationType}" but "sort" is only supported for "many".`);
}
}
// 3. Computed field.
@@ -605,7 +602,7 @@ export class ModelManager {
if (!field.relationType) {
throw new Error(`${field} on ${Model} must define a relation type in "relationType".`);
}
if (!(['one2one', 'one2many', 'many2one', 'many2many'].includes(field.relationType))) {
if (!(['many', 'one'].includes(field.relationType))) {
throw new Error(`${field} on ${Model} has invalid relation type "${field.relationType}".`);
}
if (!field.inverse) {
@@ -628,14 +625,6 @@ export class ModelManager {
if (![Model.name, 'Model'].includes(inverseField.to)) {
throw new Error(`${field} on ${Model} has its inverse ${inverseField} on ${RelatedModel} referring to an invalid model (model(${inverseField.to})).`);
}
if (
(field.relationType === 'many2many' && inverseField.relationType !== 'many2many') ||
(field.relationType === 'one2one' && inverseField.relationType !== 'one2one') ||
(field.relationType === 'one2many' && inverseField.relationType !== 'many2one') ||
(field.relationType === 'many2one' && inverseField.relationType !== 'one2many')
) {
throw new Error(`Mismatched relation types: ${field} on ${Model} (${field.relationType}) and ${inverseField} on ${RelatedModel} (${inverseField.relationType}).`);
}
}
for (const identifyingField of Model.__identifyingFieldsFlattened) {
const field = Model.__fieldMap[identifyingField];
@@ -646,8 +635,8 @@ export class ModelManager {
throw new Error(`Identifying field "${identifyingField}" on ${Model} is lacking readonly.`);
}
if (field.to) {
if (!(['one2one', 'many2one'].includes(field.relationType))) {
throw new Error(`Identifying field "${identifyingField}" on ${Model} has a relation of type "${field.relationType}" but identifying field is only supported for "one2one" and "many2one".`);
if (field.relationType !== 'one') {
throw new Error(`Identifying field "${identifyingField}" on ${Model} has a relation of type "${field.relationType}" but identifying field is only supported for "one".`);
}
const RelatedModel = this.models[field.to];
const inverseField = RelatedModel.__fieldMap[field.inverse];
@@ -697,7 +686,7 @@ export class ModelManager {
for (const field of Model.__fieldList) {
record.__values[field.fieldName] = undefined;
if (field.fieldType === 'relation') {
if (['one2many', 'many2many'].includes(field.relationType)) {
if (field.relationType === 'many') {
record.__values[field.fieldName] = new RelationSet(record, field);
}
}
@@ -1062,18 +1051,9 @@ export class ModelManager {
* @returns {ModelField}
*/
_makeInverseRelationField(Model, field) {
const relFunc =
field.relationType === 'many2many' ? ModelField.many2many
: field.relationType === 'many2one' ? ModelField.one2many
: field.relationType === 'one2many' ? ModelField.many2one
: field.relationType === 'one2one' ? ModelField.one2one
: undefined;
if (!relFunc) {
throw new Error(`Cannot compute inverse Relation of "${Model}/${field.fieldName}".`);
}
const inverseField = new ModelField(Object.assign(
{},
relFunc(Model.name, { inverse: field.fieldName }),
ModelField.many(Model.name, { inverse: field.fieldName }),
{
fieldName: `_inverse_${Model}/${field.fieldName}`,
// Allows the inverse of an identifying field to be
@@ -1,7 +1,7 @@
/** @odoo-module **/
import { registerModel } from '@mail/model/model_core';
import { attr, many2one, one2many, one2one } from '@mail/model/model_field';
import { attr, many, one } from '@mail/model/model_field';
import { insertAndReplace } from '@mail/model/model_field_command';
registerModel({
@@ -13,7 +13,7 @@ registerModel({
required: true,
}),
addressInfo: attr(),
contact: one2one('TestContact', {
contact: one('TestContact', {
inverse: 'address',
}),
},
@@ -27,19 +27,19 @@ registerModel({
readonly: true,
required: true,
}),
address: one2one('TestAddress', {
address: one('TestAddress', {
inverse: 'contact',
}),
favorite: one2one('TestHobby', {
favorite: one('TestHobby', {
default: insertAndReplace({ description: 'football' }),
}),
hobbies: one2many('TestHobby', {
hobbies: many('TestHobby', {
default: insertAndReplace([
{ description: 'hiking' },
{ description: 'fishing' },
]),
}),
tasks: one2many('TestTask', {
tasks: many('TestTask', {
inverse: 'responsible'
}),
},
@@ -68,7 +68,7 @@ registerModel({
difficulty: attr({
default: 1,
}),
responsible: many2one('TestContact', {
responsible: one('TestContact', {
inverse: 'tasks'
}),
},
@@ -1,7 +1,7 @@
/** @odoo-module **/
import { registerModel } from '@mail/model/model_core';
import { attr, many2many, many2one, one2many } from '@mail/model/model_field';
import { attr, many, one } from '@mail/model/model_field';
import { clear, insert, unlink, unlinkAll } from '@mail/model/model_field_command';
registerModel({
@@ -232,19 +232,19 @@ registerModel({
},
},
fields: {
activityViews: one2many('ActivityView', {
activityViews: many('ActivityView', {
inverse: 'activity',
isCausal: true,
}),
assignee: many2one('User'),
attachments: many2many('Attachment', {
assignee: one('User'),
attachments: many('Attachment', {
inverse: 'activities',
}),
canWrite: attr({
default: false,
}),
category: attr(),
creator: many2one('User'),
creator: one('User'),
dateCreate: attr(),
dateDeadline: attr(),
/**
@@ -265,7 +265,7 @@ registerModel({
compute: '_computeIsCurrentPartnerAssignee',
default: false,
}),
mailTemplates: many2many('MailTemplate', {
mailTemplates: many('MailTemplate', {
inverse: 'activities',
}),
/**
@@ -284,17 +284,17 @@ registerModel({
* Also, be useful when the assigned user is different from the
* "source" or "requesting" partner.
*/
requestingPartner: many2one('Partner'),
requestingPartner: one('Partner'),
state: attr(),
summary: attr(),
/**
* Determines to which "thread" (using `mail.activity.mixin` on the
* server) `this` belongs to.
*/
thread: many2one('Thread', {
thread: one('Thread', {
inverse: 'activities',
}),
type: many2one('ActivityType', {
type: one('ActivityType', {
inverse: 'activities',
}),
},
@@ -1,7 +1,7 @@
/** @odoo-module **/
import { registerModel } from '@mail/model/model_core';
import { attr, one2many, one2one } from '@mail/model/model_field';
import { attr, many, one } from '@mail/model/model_field';
import { insertAndReplace, replace } from '@mail/model/model_field_command';
registerModel({
@@ -25,12 +25,12 @@ registerModel({
},
},
fields: {
activityViews: one2many('ActivityView', {
activityViews: many('ActivityView', {
compute: '_computeActivityViews',
inverse: 'activityBoxView',
isCausal: true,
}),
chatter: one2one('Chatter', {
chatter: one('Chatter', {
inverse: 'activityBoxView',
readonly: true,
required: true,
@@ -1,7 +1,7 @@
/** @odoo-module **/
import { registerModel } from '@mail/model/model_core';
import { attr, one2one } from '@mail/model/model_field';
import { attr, one } from '@mail/model/model_field';
registerModel({
name: 'ActivityMarkDonePopoverView',
@@ -67,7 +67,7 @@ registerModel({
},
},
fields: {
activityViewOwner: one2one('ActivityView', {
activityViewOwner: one('ActivityView', {
inverse: 'activityMarkDonePopoverView',
readonly: true,
required: true,
@@ -1,13 +1,13 @@
/** @odoo-module **/
import { registerModel } from '@mail/model/model_core';
import { attr, one2many } from '@mail/model/model_field';
import { attr, many } from '@mail/model/model_field';
registerModel({
name: 'ActivityType',
identifyingFields: ['id'],
fields: {
activities: one2many('Activity', {
activities: many('Activity', {
inverse: 'type',
}),
displayName: attr(),
@@ -1,7 +1,7 @@
/** @odoo-module **/
import { registerModel } from '@mail/model/model_core';
import { attr, many2one, one2one } from '@mail/model/model_field';
import { attr, one } from '@mail/model/model_field';
import { clear, insertAndReplace } from '@mail/model/model_field_command';
import { auto_str_to_date, getLangDateFormat, getLangDatetimeFormat } from 'web.time';
@@ -140,17 +140,17 @@ registerModel({
},
},
fields: {
activity: many2one('Activity', {
activity: one('Activity', {
inverse: 'activityViews',
required: true,
readonly: true,
}),
activityBoxView: many2one('ActivityBoxView', {
activityBoxView: one('ActivityBoxView', {
inverse: 'activityViews',
readonly: true,
required: true,
}),
activityMarkDonePopoverView: one2one('ActivityMarkDonePopoverView', {
activityMarkDonePopoverView: one('ActivityMarkDonePopoverView', {
default: insertAndReplace(),
inverse: 'activityViewOwner',
isCausal: true,
@@ -173,7 +173,7 @@ registerModel({
delayLabel: attr({
compute: '_computeDelayLabel',
}),
fileUploader: one2one('FileUploader', {
fileUploader: one('FileUploader', {
compute: '_computeFileUploader',
inverse: 'activityView',
isCausal: true,
@@ -1,7 +1,7 @@
/** @odoo-module **/
import { registerModel } from '@mail/model/model_core';
import { attr, many2many, many2one } from '@mail/model/model_field';
import { attr, many, one } from '@mail/model/model_field';
import { clear, insert } from '@mail/model/model_field_command';
registerModel({
@@ -270,20 +270,20 @@ registerModel({
},
fields: {
accessToken: attr(),
activities: many2many('Activity', {
activities: many('Activity', {
inverse: 'attachments',
}),
/**
* States the attachment lists that are displaying this attachment.
*/
attachmentLists: many2many('AttachmentList', {
attachmentLists: many('AttachmentList', {
inverse: 'attachments',
}),
checksum: attr(),
/**
* States on which composer this attachment is currently being created.
*/
composer: many2one('Composer', {
composer: one('Composer', {
inverse: 'attachments',
}),
defaultSource: attr({
@@ -368,18 +368,18 @@ registerModel({
mediaType: attr({
compute: '_computeMediaType',
}),
messages: many2many('Message', {
messages: many('Message', {
inverse: 'attachments',
}),
mimetype: attr({
default: '',
}),
name: attr(),
originThread: many2one('Thread', {
originThread: one('Thread', {
inverse: 'originThreadAttachments',
}),
size: attr(),
threads: many2many('Thread', {
threads: many('Thread', {
inverse: 'attachments',
}),
type: attr(),
@@ -1,7 +1,7 @@
/** @odoo-module **/
import { registerModel } from '@mail/model/model_core';
import { attr, one2one } from '@mail/model/model_field';
import { attr, one } from '@mail/model/model_field';
import { insertAndReplace } from '@mail/model/model_field_command';
registerModel({
@@ -23,7 +23,7 @@ registerModel({
},
},
fields: {
chatter: one2one('Chatter', {
chatter: one('Chatter', {
inverse: 'attachmentBoxView',
readonly: true,
required: true,
@@ -32,7 +32,7 @@ registerModel({
* States the OWL component displaying this attachment box.
*/
component: attr(),
fileUploader: one2one('FileUploader', {
fileUploader: one('FileUploader', {
default: insertAndReplace(),
inverse: 'attachmentBoxView',
isCausal: true,
@@ -1,7 +1,7 @@
/** @odoo-module **/
import { registerModel } from '@mail/model/model_core';
import { attr, many2one } from '@mail/model/model_field';
import { attr, one } from '@mail/model/model_field';
import { insert, insertAndReplace, replace } from '@mail/model/model_field_command';
registerModel({
@@ -55,14 +55,14 @@ registerModel({
/**
* Determines the attachment of this card.
*/
attachment: many2one('Attachment', {
attachment: one('Attachment', {
readonly: true,
required: true,
}),
/**
* States the attachmentList displaying this card.
*/
attachmentList: many2one('AttachmentList', {
attachmentList: one('AttachmentList', {
inverse: 'attachmentCards',
readonly: true,
required: true,
@@ -1,7 +1,7 @@
/** @odoo-module **/
import { registerModel } from '@mail/model/model_core';
import { attr, many2one } from '@mail/model/model_field';
import { attr, one } from '@mail/model/model_field';
import { clear, insert, insertAndReplace, replace } from '@mail/model/model_field_command';
registerModel({
@@ -97,14 +97,14 @@ registerModel({
/**
* Determines the attachment of this attachment image..
*/
attachment: many2one('Attachment', {
attachment: one('Attachment', {
readonly: true,
required: true,
}),
/**
* States the attachmentList displaying this attachment image.
*/
attachmentList: many2one('AttachmentList', {
attachmentList: one('AttachmentList', {
inverse: 'attachmentImages',
readonly: true,
required: true,
@@ -1,7 +1,7 @@
/** @odoo-module **/
import { registerModel } from '@mail/model/model_core';
import { many2many, many2one, one2many, one2one } from '@mail/model/model_field';
import { many, one } from '@mail/model/model_field';
import { clear, insertAndReplace, replace } from '@mail/model/model_field_command';
registerModel({
@@ -60,14 +60,14 @@ registerModel({
/**
* States the attachments to be displayed by this attachment list.
*/
attachments: many2many('Attachment', {
attachments: many('Attachment', {
compute: '_computeAttachments',
inverse: 'attachmentLists',
}),
/**
* States the attachment cards that are displaying this nonImageAttachments.
*/
attachmentCards: one2many('AttachmentCard', {
attachmentCards: many('AttachmentCard', {
compute: '_computeAttachmentCards',
inverse: 'attachmentList',
isCausal: true,
@@ -75,7 +75,7 @@ registerModel({
/**
* States the attachment images that are displaying this imageAttachments.
*/
attachmentImages: one2many('AttachmentImage', {
attachmentImages: many('AttachmentImage', {
compute: '_computeAttachmentImages',
inverse: 'attachmentList',
isCausal: true,
@@ -83,43 +83,43 @@ registerModel({
/**
* Link with a chatter to handle attachments.
*/
chatter: one2one('Chatter', {
chatter: one('Chatter', {
inverse: 'attachmentList',
readonly: true,
}),
/**
* Link with a composer view to handle attachments.
*/
composerView: one2one('ComposerView', {
composerView: one('ComposerView', {
inverse: 'attachmentList',
readonly: true,
}),
/**
* States the attachment that are an image.
*/
imageAttachments: many2many('Attachment', {
imageAttachments: many('Attachment', {
compute: '_computeImageAttachments',
}),
message: many2one('Message', {
message: one('Message', {
related: 'messageView.message'
}),
/**
* Link with a message view to handle attachments.
*/
messageView: one2one('MessageView', {
messageView: one('MessageView', {
inverse: 'attachmentList',
readonly: true,
}),
/**
* States the attachment that are not an image.
*/
nonImageAttachments: many2many('Attachment', {
nonImageAttachments: many('Attachment', {
compute: '_computeNonImageAttachments',
}),
/**
* States the attachments that can be viewed inside the browser.
*/
viewableAttachments: many2many('Attachment', {
viewableAttachments: many('Attachment', {
compute: '_computeViewableAttachments',
}),
},
@@ -1,7 +1,7 @@
/** @odoo-module **/
import { registerModel } from '@mail/model/model_core';
import { attr, many2many, many2one, one2one } from '@mail/model/model_field';
import { attr, many, one } from '@mail/model/model_field';
registerModel({
name: 'AttachmentViewer',
@@ -47,12 +47,12 @@ registerModel({
angle: attr({
default: 0,
}),
attachment: many2one('Attachment'),
attachmentList: many2one('AttachmentList', {
attachment: one('Attachment'),
attachmentList: one('AttachmentList', {
readonly: true,
required: true,
}),
attachments: many2many('Attachment', {
attachments: many('Attachment', {
related: 'attachmentList.viewableAttachments',
}),
/**
@@ -62,7 +62,7 @@ registerModel({
/**
* Determines the dialog displaying this attachment viewer.
*/
dialog: one2one('Dialog', {
dialog: one('Dialog', {
inverse: 'attachmentViewer',
isCausal: true,
readonly: true,
@@ -1,7 +1,7 @@
/** @odoo-module **/
import { registerModel } from '@mail/model/model_core';
import { attr, many2many, many2one, one2one } from '@mail/model/model_field';
import { attr, many, one } from '@mail/model/model_field';
import { clear, insertAndReplace, link, replace, unlink, unlinkAll } from '@mail/model/model_field_command';
import { cleanSearchTerm } from '@mail/utils/utils';
@@ -175,7 +175,7 @@ registerModel({
},
},
fields: {
chatWindow: one2one('ChatWindow', {
chatWindow: one('ChatWindow', {
inverse: 'channelInvitationForm',
readonly: true,
}),
@@ -210,7 +210,7 @@ registerModel({
/**
* If set, this channel invitation form is content of related popover view.
*/
popoverViewOwner: one2one('PopoverView', {
popoverViewOwner: one('PopoverView', {
inverse: 'channelInvitationForm',
isCausal: true,
readonly: true,
@@ -236,15 +236,15 @@ registerModel({
* States all partners that are potential choices according to this
* search term.
*/
selectablePartners: many2many('Partner'),
selectablePartners: many('Partner'),
/**
* Determines all partners that are currently selected.
*/
selectedPartners: many2many('Partner'),
selectedPartners: many('Partner'),
/**
* States the thread on which this list operates (if any).
*/
thread: many2one('Thread', {
thread: one('Thread', {
compute: '_computeThread',
readonly: true,
required: true,
@@ -1,7 +1,7 @@
/** @odoo-module **/
import { registerModel } from '@mail/model/model_core';
import { attr, many2one, one2one } from '@mail/model/model_field';
import { attr, one } from '@mail/model/model_field';
import { clear, insertAndReplace, link, unlink } from '@mail/model/model_field_command';
import { markEventHandled } from '@mail/utils/utils';
@@ -365,7 +365,7 @@ registerModel({
* Determines the channel invitation form displayed by this chat window
* (if any). Only makes sense if hasInviteFeature is true.
*/
channelInvitationForm: one2one('ChannelInvitationForm', {
channelInvitationForm: one('ChannelInvitationForm', {
inverse: 'chatWindow',
isCausal: true,
}),
@@ -438,11 +438,11 @@ registerModel({
isVisible: attr({
compute: '_computeIsVisible',
}),
manager: many2one('ChatWindowManager', {
manager: one('ChatWindowManager', {
inverse: 'chatWindows',
readonly: true,
}),
managerAsNewMessage: one2one('ChatWindowManager', {
managerAsNewMessage: one('ChatWindowManager', {
inverse: 'newMessageChatWindow',
readonly: true,
}),
@@ -453,20 +453,20 @@ registerModel({
* Determines the `Thread` that should be displayed by `this`.
* If no `Thread` is linked, `this` is considered "new message".
*/
thread: one2one('Thread', {
thread: one('Thread', {
inverse: 'chatWindow',
readonly: true,
}),
/**
* States the `ThreadView` displaying `this.thread`.
*/
threadView: one2one('ThreadView', {
threadView: one('ThreadView', {
related: 'threadViewer.threadView',
}),
/**
* Determines the `ThreadViewer` managing the display of `this.thread`.
*/
threadViewer: one2one('ThreadViewer', {
threadViewer: one('ThreadViewer', {
compute: '_computeThreadViewer',
inverse: 'chatWindow',
isCausal: true,
@@ -1,7 +1,7 @@
/** @odoo-module **/
import { registerModel } from '@mail/model/model_core';
import { attr, many2one, one2many, one2one } from '@mail/model/model_field';
import { attr, many, one } from '@mail/model/model_field';
import { insertAndReplace, link, replace, unlink } from '@mail/model/model_field_command';
const BASE_VISUAL = {
@@ -327,16 +327,16 @@ registerModel({
/**
* List of ordered chat windows.
*/
allOrdered: one2many('ChatWindow', {
allOrdered: many('ChatWindow', {
compute: '_computeAllOrdered',
}),
allOrderedHidden: one2many('ChatWindow', {
allOrderedHidden: many('ChatWindow', {
compute: '_computeAllOrderedHidden',
}),
allOrderedVisible: one2many('ChatWindow', {
allOrderedVisible: many('ChatWindow', {
compute: '_computeAllOrderedVisible',
}),
chatWindows: one2many('ChatWindow', {
chatWindows: many('ChatWindow', {
inverse: 'manager',
isCausal: true,
}),
@@ -349,10 +349,10 @@ registerModel({
isHiddenMenuOpen: attr({
default: false,
}),
lastVisible: many2one('ChatWindow', {
lastVisible: one('ChatWindow', {
compute: '_computeLastVisible',
}),
newMessageChatWindow: one2one('ChatWindow', {
newMessageChatWindow: one('ChatWindow', {
inverse: 'managerAsNewMessage',
isCausal: true,
}),
@@ -1,7 +1,7 @@
/** @odoo-module **/
import { registerModel } from '@mail/model/model_core';
import { attr, many2one, one2one } from '@mail/model/model_field';
import { attr, one } from '@mail/model/model_field';
import { clear, insert, insertAndReplace, link, unlink } from '@mail/model/model_field_command';
import { OnChange } from '@mail/model/model_onchange';
@@ -270,19 +270,19 @@ registerModel({
},
},
fields: {
activityBoxView: one2one('ActivityBoxView', {
activityBoxView: one('ActivityBoxView', {
compute: '_computeActivityBoxView',
inverse: 'chatter',
isCausal: true,
}),
attachmentBoxView: one2one('AttachmentBoxView', {
attachmentBoxView: one('AttachmentBoxView', {
inverse: 'chatter',
isCausal: true,
}),
/**
* Determines the attachment list that will be used to display the attachments.
*/
attachmentList: one2one('AttachmentList', {
attachmentList: one('AttachmentList', {
compute: '_computeAttachmentList',
inverse: 'chatter',
isCausal: true,
@@ -295,7 +295,7 @@ registerModel({
/**
* Determines the composer view used to post in this chatter (if any).
*/
composerView: one2one('ComposerView', {
composerView: one('ComposerView', {
inverse: 'chatter',
isCausal: true,
}),
@@ -370,7 +370,7 @@ registerModel({
/**
* Determines the `Thread` that should be displayed by `this`.
*/
thread: many2one('Thread'),
thread: one('Thread'),
/**
* Determines the id of the thread that will be displayed by `this`.
*/
@@ -382,13 +382,13 @@ registerModel({
/**
* States the `ThreadView` displaying `this.thread`.
*/
threadView: one2one('ThreadView', {
threadView: one('ThreadView', {
related: 'threadViewer.threadView',
}),
/**
* Determines the `ThreadViewer` managing the display of `this.thread`.
*/
threadViewer: one2one('ThreadViewer', {
threadViewer: one('ThreadViewer', {
compute: '_computeThreadViewer',
inverse: 'chatter',
isCausal: true,
@@ -1,7 +1,7 @@
/** @odoo-module **/
import { registerModel } from '@mail/model/model_core';
import { attr, many2many, many2one, one2many, one2one } from '@mail/model/model_field';
import { attr, many, one } from '@mail/model/model_field';
import { clear, replace, unlink } from '@mail/model/model_field_command';
registerModel({
@@ -120,7 +120,7 @@ registerModel({
},
},
fields: {
activeThread: many2one('Thread', {
activeThread: one('Thread', {
compute: '_computeActiveThread',
readonly: true,
required: true,
@@ -128,14 +128,14 @@ registerModel({
/**
* States which attachments are currently being created in this composer.
*/
attachments: one2many('Attachment', {
attachments: many('Attachment', {
inverse: 'composer',
}),
canPostMessage: attr({
compute: '_computeCanPostMessage',
default: false,
}),
composerViews: one2many('ComposerView', {
composerViews: many('ComposerView', {
inverse: 'composer',
isCausal: true,
}),
@@ -166,13 +166,13 @@ registerModel({
* Determines whether a post_message request is currently pending.
*/
isPostingMessage: attr(),
mentionedChannels: many2many('Thread', {
mentionedChannels: many('Thread', {
compute: '_computeMentionedChannels',
}),
mentionedPartners: many2many('Partner', {
mentionedPartners: many('Partner', {
compute: '_computeMentionedPartners',
}),
messageViewInEditing: one2one('MessageView', {
messageViewInEditing: one('MessageView', {
inverse: 'composerForEditing',
readonly: true,
}),
@@ -181,7 +181,7 @@ registerModel({
* that will receive the message being composed by `this`, and that will
* also be added as follower of `this.activeThread`.
*/
recipients: many2many('Partner', {
recipients: many('Partner', {
compute: '_computeRecipients',
}),
textInputContent: attr({
@@ -199,7 +199,7 @@ registerModel({
/**
* States the thread which this composer represents the state (if any).
*/
thread: one2one('Thread', {
thread: one('Thread', {
inverse: 'composer',
readonly: true,
}),
@@ -2,7 +2,7 @@
import { emojis } from '@mail/js/emojis';
import { registerModel } from '@mail/model/model_core';
import { attr, many2many, many2one, one2one } from '@mail/model/model_field';
import { attr, many, one } from '@mail/model/model_field';
import { clear, insertAndReplace, link, replace, unlink, unlinkAll } from '@mail/model/model_field_command';
import { OnChange } from '@mail/model/model_onchange';
import { addLink, escapeAndCompactTextContent, parseAndTransform } from '@mail/js/utils';
@@ -917,13 +917,13 @@ registerModel({
* is highlighted in the UI and it will be the selected record if the
* suggestion is confirmed by the user.
*/
activeSuggestedRecord: many2one('Model', {
activeSuggestedRecord: one('Model', {
compute: '_computeActiveSuggestedRecord',
}),
/**
* Determines the attachment list that will be used to display the attachments.
*/
attachmentList: one2one('AttachmentList', {
attachmentList: one('AttachmentList', {
compute: '_computeAttachmentList',
inverse: 'composerView',
isCausal: true,
@@ -936,7 +936,7 @@ registerModel({
/**
* States the chatter which this composer allows editing (if any).
*/
chatter: one2one('Chatter', {
chatter: one('Chatter', {
inverse: 'composerView',
readonly: true,
}),
@@ -947,7 +947,7 @@ registerModel({
/**
* States the composer state that is displayed by this composer view.
*/
composer: many2one('Composer', {
composer: one('Composer', {
compute: '_computeComposer',
inverse: 'composerViews',
required: true,
@@ -959,7 +959,7 @@ registerModel({
/**
* Determines the emojis popover that is active on this composer view.
*/
emojisPopoverView: one2one('PopoverView', {
emojisPopoverView: one('PopoverView', {
inverse: 'composerViewOwnerAsEmoji',
isCausal: true,
}),
@@ -969,10 +969,10 @@ registerModel({
* process. 2 arbitrary lists can be provided and the second is defined
* as "extra".
*/
extraSuggestedRecords: many2many('Model', {
extraSuggestedRecords: many('Model', {
compute: '_computeExtraSuggestedRecords',
}),
fileUploader: one2one('FileUploader', {
fileUploader: one('FileUploader', {
default: insertAndReplace(),
inverse: 'composerView',
isCausal: true,
@@ -1003,13 +1003,13 @@ registerModel({
* process. 2 arbitrary lists can be provided and the first is defined
* as "main".
*/
mainSuggestedRecords: many2many('Model', {
mainSuggestedRecords: many('Model', {
compute: '_computeMainSuggestedRecords',
}),
/**
* States the message view on which this composer allows editing (if any).
*/
messageViewInEditing: one2one('MessageView', {
messageViewInEditing: one('MessageView', {
inverse: 'composerViewInEditing',
readonly: true,
}),
@@ -1065,7 +1065,7 @@ registerModel({
/**
* States the thread view on which this composer allows editing (if any).
*/
threadView: one2one('ThreadView', {
threadView: one('ThreadView', {
inverse: 'composerView',
readonly: true,
}),
@@ -1,7 +1,7 @@
/** @odoo-module **/
import { addFields, patchIdentifyingFields, patchRecordMethods } from '@mail/model/model_core';
import { one2one } from '@mail/model/model_field';
import { one } from '@mail/model/model_field';
import { replace } from '@mail/model/model_field_command';
// ensure that the model definition is loaded before the patch
import '@mail/models/composer_view/composer_view';
@@ -16,7 +16,7 @@ patchRecordMethods('ComposerView', {
});
addFields('ComposerView', {
qunitTest: one2one('QUnitTest', {
qunitTest: one('QUnitTest', {
inverse: 'composerView',
readonly: true,
}),
@@ -1,7 +1,7 @@
/** @odoo-module **/
import { registerModel } from '@mail/model/model_core';
import { attr, many2one, one2one } from '@mail/model/model_field';
import { attr, one } from '@mail/model/model_field';
import { clear, replace } from '@mail/model/model_field_command';
registerModel({
@@ -52,7 +52,7 @@ registerModel({
},
},
fields: {
attachmentViewer: one2one('AttachmentViewer', {
attachmentViewer: one('AttachmentViewer', {
isCausal: true,
inverse: 'dialog',
readonly: true,
@@ -61,7 +61,7 @@ registerModel({
compute: '_computeComponentName',
required: true,
}),
followerSubtypeList: one2one('FollowerSubtypeList', {
followerSubtypeList: one('FollowerSubtypeList', {
isCausal: true,
inverse: 'dialog',
readonly: true,
@@ -70,7 +70,7 @@ registerModel({
compute: '_computeIsCloseable',
default: true,
}),
manager: many2one('DialogManager', {
manager: one('DialogManager', {
inverse: 'dialogs',
readonly: true,
}),
@@ -79,7 +79,7 @@ registerModel({
* a UI component, such as AttachmentViewer. These records must be
* created from @see `DialogManager:open()`.
*/
record: one2one('Model', {
record: one('Model', {
compute: '_computeRecord',
isCausal: true,
readonly: true,
@@ -1,14 +1,14 @@
/** @odoo-module **/
import { registerModel } from '@mail/model/model_core';
import { one2many } from '@mail/model/model_field';
import { many } from '@mail/model/model_field';
registerModel({
name: 'DialogManager',
identifyingFields: ['messaging'],
fields: {
// FIXME: dependent on implementation that uses insert order in relations!!
dialogs: one2many('Dialog', {
dialogs: many('Dialog', {
inverse: 'manager',
isCausal: true,
}),
@@ -1,7 +1,7 @@
/** @odoo-module **/
import { registerModel } from '@mail/model/model_core';
import { attr, many2one, one2one } from '@mail/model/model_field';
import { attr, one } from '@mail/model/model_field';
import { clear, insertAndReplace, link, unlink } from '@mail/model/model_field_command';
const { escape } = owl;
@@ -346,14 +346,14 @@ registerModel({
/**
* Discuss sidebar category for `channel` type channel threads.
*/
categoryChannel: one2one('DiscussSidebarCategory', {
categoryChannel: one('DiscussSidebarCategory', {
inverse: 'discussAsChannel',
isCausal: true,
}),
/**
* Discuss sidebar category for `chat` type channel threads.
*/
categoryChat: one2one('DiscussSidebarCategory', {
categoryChat: one('DiscussSidebarCategory', {
inverse: 'discussAsChat',
isCausal: true,
}),
@@ -404,7 +404,7 @@ registerModel({
menu_id: attr({
default: null,
}),
notificationListView: one2one('NotificationListView', {
notificationListView: one('NotificationListView', {
compute: '_computeNotificationListView',
inverse: 'discussOwner',
isCausal: true,
@@ -413,7 +413,7 @@ registerModel({
* The navbar view on the discuss app when in mobile and when not
* replying to a message from inbox.
*/
mobileMessagingNavbarView: one2one('MobileMessagingNavbarView', {
mobileMessagingNavbarView: one('MobileMessagingNavbarView', {
compute: '_computeMobileMessagingNavbarView',
inverse: 'discuss',
isCausal: true,
@@ -428,19 +428,19 @@ registerModel({
/**
* Determines the `Thread` that should be displayed by `this`.
*/
thread: many2one('Thread', {
thread: one('Thread', {
compute: '_computeThread',
}),
/**
* States the `ThreadView` displaying `this.thread`.
*/
threadView: one2one('ThreadView', {
threadView: one('ThreadView', {
related: 'threadViewer.threadView',
}),
/**
* Determines the `ThreadViewer` managing the display of `this.thread`.
*/
threadViewer: one2one('ThreadViewer', {
threadViewer: one('ThreadViewer', {
compute: '_computeThreadViewer',
inverse: 'discuss',
isCausal: true,
@@ -1,6 +1,6 @@
/** @odoo-module **/
import { attr, one2one } from '@mail/model/model_field';
import { attr, one } from '@mail/model/model_field';
import { registerModel } from '@mail/model/model_core';
import { clear, insertAndReplace, link } from '@mail/model/model_field_command';
@@ -54,7 +54,7 @@ registerModel({
/**
* States the channel linked to this discuss public view.
*/
channel: one2one('Thread', {
channel: one('Thread', {
readonly: true,
required: true,
}),
@@ -72,21 +72,21 @@ registerModel({
/**
* States the thread view linked to this discuss public view.
*/
threadView: one2one('ThreadView', {
threadView: one('ThreadView', {
readonly: true,
related: 'threadViewer.threadView',
}),
/**
* States the thread viewer linked to this discuss public view.
*/
threadViewer: one2one('ThreadViewer', {
threadViewer: one('ThreadViewer', {
inverse: 'discussPublicView',
isCausal: true,
}),
/**
* States the welcome view linked to this discuss public view.
*/
welcomeView: one2one('WelcomeView', {
welcomeView: one('WelcomeView', {
inverse: 'discussPublicView',
isCausal: true,
}),
@@ -1,7 +1,7 @@
/** @odoo-module **/
import { registerModel } from '@mail/model/model_core';
import { attr, one2many, one2one } from '@mail/model/model_field';
import { attr, many, one } from '@mail/model/model_field';
import { clear, insertAndReplace, replace } from '@mail/model/model_field_command';
import { OnChange } from '@mail/model/model_onchange';
@@ -193,7 +193,7 @@ registerModel({
* The category item which is active and belongs
* to the category.
*/
activeItem: one2one('DiscussSidebarCategoryItem', {
activeItem: one('DiscussSidebarCategoryItem', {
compute: '_computeActiveItem',
}),
/**
@@ -209,7 +209,7 @@ registerModel({
* Determines the discuss sidebar category items that are displayed by
* this discuss sidebar category.
*/
categoryItems: one2many('DiscussSidebarCategoryItem', {
categoryItems: many('DiscussSidebarCategoryItem', {
inverse: 'category',
isCausal: true,
sort: '_sortDefinitionCategoryItems',
@@ -223,11 +223,11 @@ registerModel({
readonly: true,
sum: 'categoryItems.categoryCounterContribution',
}),
discussAsChannel: one2one('Discuss', {
discussAsChannel: one('Discuss', {
inverse: 'categoryChannel',
readonly: true,
}),
discussAsChat: one2one('Discuss', {
discussAsChat: one('Discuss', {
inverse: 'categoryChat',
readonly: true,
}),
@@ -235,7 +235,7 @@ registerModel({
* Determines the filtered and sorted discuss sidebar category items
* that are displayed by this discuss sidebar category.
*/
filteredCategoryItems: one2many('DiscussSidebarCategoryItem', {
filteredCategoryItems: many('DiscussSidebarCategoryItem', {
compute: '_computeFilteredCategoryItems',
readonly: true,
}),
@@ -1,7 +1,7 @@
/** @odoo-module **/
import { registerModel } from '@mail/model/model_core';
import { attr, many2one, one2one } from '@mail/model/model_field';
import { attr, one } from '@mail/model/model_field';
import { clear } from '@mail/model/model_field_command';
import Dialog from 'web.Dialog';
@@ -212,7 +212,7 @@ registerModel({
/**
* Determines the discuss sidebar category displaying this item.
*/
category: many2one('DiscussSidebarCategory', {
category: one('DiscussSidebarCategory', {
inverse: 'categoryItems',
readonly: true,
required: true,
@@ -270,7 +270,7 @@ registerModel({
/**
* The related channel thread.
*/
channel: one2one('Thread', {
channel: one('Thread', {
inverse: 'discussSidebarCategoryItem',
readonly: true,
required: true,
@@ -1,7 +1,7 @@
/** @odoo-module **/
import { registerModel } from '@mail/model/model_core';
import { one2one } from '@mail/model/model_field';
import { one } from '@mail/model/model_field';
registerModel({
name: 'EmojiListView',
@@ -19,7 +19,7 @@ registerModel({
},
},
fields: {
popoverViewOwner: one2one('PopoverView', {
popoverViewOwner: one('PopoverView', {
inverse: 'emojiListView',
readonly: true,
required: true,
@@ -1,7 +1,7 @@
/** @odoo-module **/
import { registerModel } from '@mail/model/model_core';
import { attr, many2one, one2one } from '@mail/model/model_field';
import { attr, one } from '@mail/model/model_field';
import { clear, replace } from '@mail/model/model_field_command';
import core from 'web.core';
@@ -174,22 +174,22 @@ registerModel({
},
},
fields: {
activityView: one2one('ActivityView', {
activityView: one('ActivityView', {
inverse: 'fileUploader',
readonly: true,
}),
attachmentBoxView: one2one('AttachmentBoxView', {
attachmentBoxView: one('AttachmentBoxView', {
inverse: 'fileUploader',
readonly: true,
}),
composerView: one2one('ComposerView', {
composerView: one('ComposerView', {
inverse: 'fileUploader',
readonly: true,
}),
fileInput: attr({
compute: '_computeFileInput',
}),
thread: many2one('Thread', {
thread: one('Thread', {
compute: '_computeThread',
readonly: true,
required: true,
@@ -1,7 +1,7 @@
/** @odoo-module **/
import { registerModel } from '@mail/model/model_core';
import { attr, many2many, many2one, one2many } from '@mail/model/model_field';
import { attr, many, one } from '@mail/model/model_field';
import { clear, insert, insertAndReplace, link, replace, unlink, unlinkAll } from '@mail/model/model_field_command';
registerModel({
@@ -142,7 +142,7 @@ registerModel({
},
},
fields: {
followedThread: many2one('Thread', {
followedThread: one('Thread', {
inverse: 'followers',
}),
id: attr({
@@ -155,14 +155,14 @@ registerModel({
isEditable: attr({
default: false,
}),
partner: many2one('Partner', {
partner: one('Partner', {
required: true,
}),
selectedSubtypes: many2many('FollowerSubtype'),
subtypeList: one2many('FollowerSubtypeList', {
selectedSubtypes: many('FollowerSubtype'),
subtypeList: many('FollowerSubtypeList', {
inverse: 'follower',
isCausal: true,
}),
subtypes: many2many('FollowerSubtype'),
subtypes: many('FollowerSubtype'),
},
});
@@ -1,7 +1,7 @@
/** @odoo-module **/
import { registerModel } from '@mail/model/model_core';
import { attr, many2one, one2one } from '@mail/model/model_field';
import { attr, one } from '@mail/model/model_field';
registerModel({
name: 'FollowerSubtypeList',
@@ -25,12 +25,12 @@ registerModel({
/**
* States the dialog displaying this follower subtype list.
*/
dialog: one2one('Dialog', {
dialog: one('Dialog', {
inverse: 'followerSubtypeList',
isCausal: true,
readonly: true,
}),
follower: many2one('Follower', {
follower: one('Follower', {
inverse: 'subtypeList',
readonly: true,
required: true,
+4 -4
View File
@@ -1,6 +1,6 @@
/** @odoo-module **/
import { attr, one2many, one2one } from '@mail/model/model_field';
import { attr, many, one } from '@mail/model/model_field';
import { registerModel } from '@mail/model/model_core';
registerModel({
@@ -32,7 +32,7 @@ registerModel({
},
},
fields: {
authoredMessages: one2many('Message', {
authoredMessages: many('Message', {
inverse: 'guestAuthor',
}),
avatarUrl: attr({
@@ -43,10 +43,10 @@ registerModel({
readonly: true,
}),
name: attr(),
rtcSessions: one2many('RtcSession', {
rtcSessions: many('RtcSession', {
inverse: 'guest',
}),
volumeSetting: one2one('VolumeSetting', {
volumeSetting: one('VolumeSetting', {
inverse: 'guest',
}),
},
@@ -1,7 +1,7 @@
/** @odoo-module **/
import { registerModel } from '@mail/model/model_core';
import { attr, many2many } from '@mail/model/model_field';
import { attr, many } from '@mail/model/model_field';
registerModel({
name: 'MailTemplate',
@@ -47,7 +47,7 @@ registerModel({
},
},
fields: {
activities: many2many('Activity', {
activities: many('Activity', {
inverse: 'mailTemplates',
}),
id: attr({
@@ -1,6 +1,6 @@
/** @odoo-module **/
import { attr, one2one } from '@mail/model/model_field';
import { attr, one } from '@mail/model/model_field';
import { registerModel } from '@mail/model/model_core';
registerModel({
@@ -175,7 +175,7 @@ registerModel({
/**
* States the welcome view containing this media preview.
*/
welcomeView: one2one('WelcomeView', {
welcomeView: one('WelcomeView', {
inverse: 'mediaPreview',
readonly: true,
}),
@@ -1,7 +1,7 @@
/** @odoo-module **/
import { registerModel } from '@mail/model/model_core';
import { attr, many2many, many2one, one2many } from '@mail/model/model_field';
import { attr, many, one } from '@mail/model/model_field';
import { clear, insert, insertAndReplace, replace, unlinkAll } from '@mail/model/model_field_command';
import emojis from '@mail/js/emojis';
import { addLink, htmlToTextContentInline, parseAndTransform, timeFromNow } from '@mail/js/utils';
@@ -551,10 +551,10 @@ registerModel({
authorName: attr({
compute: '_computeAuthorName',
}),
attachments: many2many('Attachment', {
attachments: many('Attachment', {
inverse: 'messages',
}),
author: many2one('Partner'),
author: one('Partner'),
/**
* This value is meant to be returned by the server
* (and has been sanitized before stored into db).
@@ -594,10 +594,10 @@ registerModel({
compute: '_computeDateFromNow',
}),
email_from: attr(),
failureNotifications: one2many('Notification', {
failureNotifications: many('Notification', {
compute: '_computeFailureNotifications',
}),
guestAuthor: many2one('Guest', {
guestAuthor: one('Guest', {
inverse: 'authoredMessages',
}),
/**
@@ -723,7 +723,7 @@ registerModel({
* Groups of reactions per content allowing to know the number of
* reactions for each.
*/
messageReactionGroups: one2many('MessageReactionGroup', {
messageReactionGroups: many('MessageReactionGroup', {
inverse: 'message',
isCausal: true,
}),
@@ -731,18 +731,18 @@ registerModel({
/**
* States the views that are displaying this message.
*/
messageViews: one2many('MessageView', {
messageViews: many('MessageView', {
inverse: 'message',
isCausal: true,
}),
notifications: one2many('Notification', {
notifications: many('Notification', {
inverse: 'message',
isCausal: true,
}),
/**
* Origin thread of this message (if any).
*/
originThread: many2one('Thread', {
originThread: one('Thread', {
inverse: 'messagesAsOriginThread',
}),
/**
@@ -751,7 +751,7 @@ registerModel({
* (parent_id in python) that should be ignored for the purpose of this
* feature.
*/
parentMessage: many2one('Message'),
parentMessage: one('Message'),
/**
* This value is meant to be based on field body which is
* returned by the server (and has been sanitized before stored into db).
@@ -768,7 +768,7 @@ registerModel({
/**
* All threads that this message is linked to. This field is read-only.
*/
threads: many2many('Thread', {
threads: many('Thread', {
compute: '_computeThreads',
inverse: 'messages',
}),
@@ -1,7 +1,7 @@
/** @odoo-module **/
import { registerModel } from '@mail/model/model_core';
import { attr, many2one, one2one } from '@mail/model/model_field';
import { attr, one } from '@mail/model/model_field';
import { clear, insertAndReplace, replace } from '@mail/model/model_field_command';
import { markEventHandled } from '@mail/utils/utils';
@@ -144,13 +144,13 @@ registerModel({
/**
* States the message on which this action message list operates.
*/
message: many2one('Message', {
message: one('Message', {
related: 'messageView.message',
}),
/**
* States the message view that controls this message action list.
*/
messageView: one2one('MessageView', {
messageView: one('MessageView', {
inverse: 'messageActionList',
readonly: true,
required: true,
@@ -159,7 +159,7 @@ registerModel({
* Determines the message view that this message action list will use to
* display this message in this delete confirmation dialog.
*/
messageViewForDelete: one2one('MessageView', {
messageViewForDelete: one('MessageView', {
compute: '_computeMessageViewForDelete',
inverse: 'messageActionListWithDelete',
isCausal: true,
@@ -167,7 +167,7 @@ registerModel({
/**
* Determines the reaction popover that is active on this message action list.
*/
reactionPopoverView: one2one('PopoverView', {
reactionPopoverView: one('PopoverView', {
inverse: 'messageActionListOwnerAsReaction',
isCausal: true,
}),
@@ -1,7 +1,7 @@
/** @odoo-module **/
import { registerModel } from '@mail/model/model_core';
import { attr, one2one } from '@mail/model/model_field';
import { attr, one } from '@mail/model/model_field';
import { replace } from '@mail/model/model_field_command';
import { markEventHandled } from '@mail/utils/utils';
@@ -59,7 +59,7 @@ registerModel({
hasBodyBackLink: attr({
compute: '_computeHasBodyBackLink',
}),
messageView: one2one('MessageView', {
messageView: one('MessageView', {
inverse: 'messageInReplyToView',
readonly: true,
required: true,
@@ -1,7 +1,7 @@
/** @odoo-module **/
import { registerModel } from '@mail/model/model_core';
import { attr, one2one } from '@mail/model/model_field';
import { attr, one } from '@mail/model/model_field';
registerModel({
name: 'MessageListView',
@@ -11,7 +11,7 @@ registerModel({
* States the OWL component of this message list view
*/
component: attr(),
threadViewOwner: one2one('ThreadView', {
threadViewOwner: one('ThreadView', {
inverse: 'messageListView',
readonly: true,
required: true,
@@ -1,7 +1,7 @@
/** @odoo-module **/
import { registerModel } from '@mail/model/model_core';
import { attr, many2many, many2one } from '@mail/model/model_field';
import { attr, many, one } from '@mail/model/model_field';
import { insertAndReplace } from '@mail/model/model_field_command';
import { markEventHandled } from '@mail/utils/utils';
@@ -83,12 +83,12 @@ registerModel({
/**
* States the guests that have used this reaction on this message.
*/
guests: many2many('Guest'),
guests: many('Guest'),
hasUserReacted: attr({
compute: '_computeHasUserReacted',
default: false,
}),
message: many2one('Message', {
message: one('Message', {
compute: '_computeMessage',
inverse: 'messageReactionGroups',
readonly: true,
@@ -101,7 +101,7 @@ registerModel({
/**
* States the partners that have used this reaction on this message.
*/
partners: many2many('Partner'),
partners: many('Partner'),
summary: attr({
compute: '_computeSummary',
}),
@@ -1,7 +1,7 @@
/** @odoo-module **/
import { registerModel } from '@mail/model/model_core';
import { attr, many2many, many2one } from '@mail/model/model_field';
import { attr, many, one } from '@mail/model/model_field';
import { replace, unlinkAll } from '@mail/model/model_field_command';
registerModel({
@@ -225,20 +225,20 @@ registerModel({
/**
* The message concerned by this seen indicator.
*/
message: many2one('Message', {
message: one('Message', {
readonly: true,
required: true,
}),
partnersThatHaveFetched: many2many('Partner', {
partnersThatHaveFetched: many('Partner', {
compute: '_computePartnersThatHaveFetched',
}),
partnersThatHaveSeen: many2many('Partner', {
partnersThatHaveSeen: many('Partner', {
compute: '_computePartnersThatHaveSeen',
}),
/**
* The thread concerned by this seen indicator.
*/
thread: many2one('Thread', {
thread: one('Thread', {
inverse: 'messageSeenIndicators',
readonly: true,
required: true,
@@ -1,7 +1,7 @@
/** @odoo-module **/
import { registerModel } from '@mail/model/model_core';
import { attr, many2one, one2one } from '@mail/model/model_field';
import { attr, one } from '@mail/model/model_field';
import { clear, insertAndReplace, replace } from '@mail/model/model_field_command';
registerModel({
@@ -132,7 +132,7 @@ registerModel({
* Determines the attachment list displaying the attachments of this
* message (if any).
*/
attachmentList: one2one('AttachmentList', {
attachmentList: one('AttachmentList', {
compute: '_computeAttachmentList',
inverse: 'messageView',
isCausal: true,
@@ -142,14 +142,14 @@ registerModel({
* States the component displaying this message view (if any).
*/
component: attr(),
composerForEditing: one2one('Composer', {
composerForEditing: one('Composer', {
inverse: 'messageViewInEditing',
isCausal: true,
}),
/**
* Determines the composer that is used to edit this message (if any).
*/
composerViewInEditing: one2one('ComposerView', {
composerViewInEditing: one('ComposerView', {
inverse: 'messageViewInEditing',
isCausal: true,
}),
@@ -183,7 +183,7 @@ registerModel({
/**
* Determines the message action list of this message view (if any).
*/
messageActionList: one2one('MessageActionList', {
messageActionList: one('MessageActionList', {
compute: '_computeMessageActionList',
inverse: 'messageView',
isCausal: true,
@@ -193,7 +193,7 @@ registerModel({
* States the message action list that is displaying this message view
* in its delete confirmation view.
*/
messageActionListWithDelete: one2one('MessageActionList', {
messageActionListWithDelete: one('MessageActionList', {
inverse: 'messageViewForDelete',
isCausal: true,
readonly: true,
@@ -201,7 +201,7 @@ registerModel({
/**
* Determines the message that is displayed by this message view.
*/
message: many2one('Message', {
message: one('Message', {
inverse: 'messageViews',
readonly: true,
required: true,
@@ -210,7 +210,7 @@ registerModel({
* States the message in reply to view that displays the message of
* which this message is a reply to (if any).
*/
messageInReplyToView: one2one('MessageInReplyToView', {
messageInReplyToView: one('MessageInReplyToView', {
compute: '_computeMessageInReplyToView',
inverse: 'messageView',
isCausal: true,
@@ -219,7 +219,7 @@ registerModel({
/**
* States the thread view that is displaying this messages (if any).
*/
threadView: many2one('ThreadView', {
threadView: one('ThreadView', {
inverse: 'messageViews',
readonly: true,
}),
@@ -1,12 +1,12 @@
/** @odoo-module **/
import { addFields, patchIdentifyingFields } from '@mail/model/model_core';
import { one2one } from '@mail/model/model_field';
import { one } from '@mail/model/model_field';
// ensure that the model definition is loaded before the patch
import '@mail/models/message_view/message_view';
addFields('MessageView', {
qunitTest: one2one('QUnitTest', {
qunitTest: one('QUnitTest', {
inverse: 'messageView',
readonly: true,
}),
@@ -1,7 +1,7 @@
/** @odoo-module **/
import { registerModel } from '@mail/model/model_core';
import { attr, many2many, many2one, one2many, one2one } from '@mail/model/model_field';
import { attr, many, one } from '@mail/model/model_field';
import { OnChange } from '@mail/model/model_onchange';
import { insertAndReplace, link, unlink } from '@mail/model/model_field_command';
import { makeDeferred } from '@mail/utils/deferred/deferred';
@@ -218,7 +218,7 @@ registerModel({
* Inverse of the messaging field present on all models. This field
* therefore contains all existing records.
*/
allRecords: one2many('Model', {
allRecords: many('Model', {
inverse: 'messaging',
isCausal: true,
}),
@@ -229,23 +229,23 @@ registerModel({
autofetchPartnerImStatus: attr({
default: true,
}),
cannedResponses: one2many('CannedResponse'),
chatWindowManager: one2one('ChatWindowManager', {
cannedResponses: many('CannedResponse'),
chatWindowManager: one('ChatWindowManager', {
default: insertAndReplace(),
isCausal: true,
readonly: true,
}),
commands: one2many('ChannelCommand'),
commands: many('ChannelCommand'),
companyName: attr(),
currentGuest: one2one('Guest'),
currentPartner: one2one('Partner'),
currentUser: one2one('User'),
device: one2one('Device', {
currentGuest: one('Guest'),
currentPartner: one('Partner'),
currentUser: one('User'),
device: one('Device', {
default: insertAndReplace(),
isCausal: true,
readonly: true,
}),
dialogManager: one2one('DialogManager', {
dialogManager: one('DialogManager', {
default: insertAndReplace(),
isCausal: true,
readonly: true,
@@ -256,20 +256,20 @@ registerModel({
disableAnimation: attr({
default: false,
}),
discuss: one2one('Discuss', {
discuss: one('Discuss', {
default: insertAndReplace(),
isCausal: true,
readonly: true,
}),
focusedRtcSession: one2one('RtcSession'),
focusedRtcSession: one('RtcSession'),
/**
* Mailbox History.
*/
history: one2one('Thread'),
history: one('Thread'),
/**
* Mailbox Inbox.
*/
inbox: one2one('Thread'),
inbox: one('Thread'),
/**
* Promise that will be resolved when messaging is initialized.
*/
@@ -278,7 +278,7 @@ registerModel({
required: true,
readonly: true,
}),
initializer: one2one('MessagingInitializer', {
initializer: one('MessagingInitializer', {
default: insertAndReplace(),
isCausal: true,
readonly: true,
@@ -305,7 +305,7 @@ registerModel({
isQUnitTest: attr({
default: false,
}),
locale: one2one('Locale', {
locale: one('Locale', {
default: insertAndReplace(),
isCausal: true,
readonly: true,
@@ -325,12 +325,12 @@ registerModel({
readonly: true,
required: true,
}),
messagingMenu: one2one('MessagingMenu', {
messagingMenu: one('MessagingMenu', {
default: insertAndReplace(),
isCausal: true,
readonly: true,
}),
notificationHandler: one2one('MessagingNotificationHandler', {
notificationHandler: one('MessagingNotificationHandler', {
default: insertAndReplace(),
isCausal: true,
readonly: true,
@@ -338,25 +338,25 @@ registerModel({
outOfFocusUnreadMessageCounter: attr({
default: 0,
}),
partnerRoot: many2one('Partner'),
partnerRoot: one('Partner'),
/**
* Determines which partners should be considered the public partners,
* which are special partners notably used in livechat.
*/
publicPartners: many2many('Partner'),
publicPartners: many('Partner'),
/**
* Threads for which the current partner has a pending invitation.
* It is computed from the inverse relation for performance reasons.
*/
ringingThreads: one2many('Thread', {
ringingThreads: many('Thread', {
inverse: 'messagingAsRingingThread',
}),
rtc: one2one('Rtc', {
rtc: one('Rtc', {
default: insertAndReplace(),
isCausal: true,
readonly: true,
}),
soundEffects: one2one('SoundEffects', {
soundEffects: one('SoundEffects', {
default: insertAndReplace(),
isCausal: true,
readonly: true,
@@ -364,14 +364,14 @@ registerModel({
/**
* Mailbox Starred.
*/
starred: one2one('Thread'),
time: one2one('Time', {
starred: one('Thread'),
time: one('Time', {
default: insertAndReplace(),
isCausal: true,
readonly: true,
required: true,
}),
userSetting: one2one('UserSetting', {
userSetting: one('UserSetting', {
isCausal: true,
}),
},
@@ -1,7 +1,7 @@
/** @odoo-module **/
import { registerModel } from '@mail/model/model_core';
import { attr, one2many, one2one } from '@mail/model/model_field';
import { attr, many, one } from '@mail/model/model_field';
import { clear, insertAndReplace } from '@mail/model/model_field_command';
registerModel({
@@ -94,7 +94,7 @@ registerModel({
isOpen: attr({
default: false,
}),
notificationListView: one2one('NotificationListView', {
notificationListView: one('NotificationListView', {
compute: '_computeNotificationListView',
inverse: 'messagingMenuOwner',
isCausal: true,
@@ -102,7 +102,7 @@ registerModel({
/**
* The navbar view on the messaging menu when in mobile.
*/
mobileMessagingNavbarView: one2one('MobileMessagingNavbarView', {
mobileMessagingNavbarView: one('MobileMessagingNavbarView', {
compute: '_computeMobileMessagingNavbarView',
inverse: 'messagingMenu',
isCausal: true,
@@ -110,7 +110,7 @@ registerModel({
/**
* States all the pinned channels that have unread messages.
*/
pinnedAndUnreadChannels: one2many('Thread', {
pinnedAndUnreadChannels: many('Thread', {
inverse: 'messagingMenuAsPinnedAndUnreadChannel',
readonly: true,
}),
@@ -1,7 +1,7 @@
/** @odoo-module **/
import { registerModel } from '@mail/model/model_core';
import { attr, one2one } from '@mail/model/model_field';
import { attr, one } from '@mail/model/model_field';
import { clear, replace } from '@mail/model/model_field_command';
registerModel({
@@ -96,11 +96,11 @@ registerModel({
activeTabId: attr({
compute: '_computeActiveTabId',
}),
discuss: one2one('Discuss', {
discuss: one('Discuss', {
inverse: 'mobileMessagingNavbarView',
readonly: true,
}),
messagingMenu: one2one('MessagingMenu', {
messagingMenu: one('MessagingMenu', {
inverse: 'mobileMessagingNavbarView',
readonly: true,
}),
+2 -2
View File
@@ -2,7 +2,7 @@
import { registerModel } from '@mail/model/model_core';
import { RecordDeletedError } from '@mail/model/model_errors';
import { many2one } from '@mail/model/model_field';
import { one } from '@mail/model/model_field';
import { insertAndReplace } from '@mail/model/model_field_command';
/**
@@ -258,7 +258,7 @@ registerModel({
* States the messaging singleton. Automatically assigned by the model
* manager at creation.
*/
messaging: many2one('Messaging', {
messaging: one('Messaging', {
default: insertAndReplace(),
inverse: 'allRecords',
readonly: true,
@@ -1,7 +1,7 @@
/** @odoo-module **/
import { registerModel } from '@mail/model/model_core';
import { attr, many2one } from '@mail/model/model_field';
import { attr, one } from '@mail/model/model_field';
import { clear, insert, insertAndReplace, unlinkAll } from '@mail/model/model_field_command';
registerModel({
@@ -140,15 +140,15 @@ registerModel({
isFromCurrentUser: attr({
compute: '_computeIsFromCurrentUser',
}),
message: many2one('Message', {
message: one('Message', {
inverse: 'notifications',
}),
notificationGroup: many2one('NotificationGroup', {
notificationGroup: one('NotificationGroup', {
compute: '_computeNotificationGroup',
inverse: 'notifications',
}),
notification_status: attr(),
notification_type: attr(),
partner: many2one('Partner'),
partner: one('Partner'),
},
});
@@ -1,7 +1,7 @@
/** @odoo-module **/
import { registerModel } from '@mail/model/model_core';
import { attr, many2one, one2many } from '@mail/model/model_field';
import { attr, many, one } from '@mail/model/model_field';
import { clear, insert, unlink } from '@mail/model/model_field_command';
import { OnChange } from '@mail/model/model_onchange';
@@ -124,10 +124,10 @@ registerModel({
notification_type: attr({
readonly: true,
}),
notifications: one2many('Notification', {
notifications: many('Notification', {
inverse: 'notificationGroup',
}),
notificationGroupViews: one2many('NotificationGroupView', {
notificationGroupViews: many('NotificationGroupView', {
inverse: 'notificationGroup',
isCausal: true,
}),
@@ -148,7 +148,7 @@ registerModel({
/**
* Related thread when the notification group concerns a single thread.
*/
thread: many2one('Thread', {
thread: one('Thread', {
compute: '_computeThread',
}),
},
@@ -1,18 +1,18 @@
/** @odoo-module **/
import { registerModel } from '@mail/model/model_core';
import { many2one } from '@mail/model/model_field';
import { one } from '@mail/model/model_field';
registerModel({
name: 'NotificationGroupView',
identifyingFields: ['notificationListViewOwner', 'notificationGroup'],
fields: {
notificationGroup: many2one('NotificationGroup', {
notificationGroup: one('NotificationGroup', {
inverse: 'notificationGroupViews',
readonly: true,
required: true,
}),
notificationListViewOwner: many2one('NotificationListView', {
notificationListViewOwner: one('NotificationListView', {
inverse: 'notificationGroupViews',
readonly: true,
required: true,
@@ -1,7 +1,7 @@
/** @odoo-module **/
import { registerModel } from '@mail/model/model_core';
import { attr, many2many, one2many, one2one } from '@mail/model/model_field';
import { attr, many, one } from '@mail/model/model_field';
import { clear, insertAndReplace, replace } from '@mail/model/model_field_command';
registerModel({
@@ -185,40 +185,40 @@ registerModel({
},
},
fields: {
discussOwner: one2one('Discuss', {
discussOwner: one('Discuss', {
inverse: 'notificationListView',
readonly: true,
}),
filter: attr({
compute: '_computeFilter',
}),
filteredThreads: many2many('Thread', {
filteredThreads: many('Thread', {
compute: '_computeFilteredThreads',
}),
messagingMenuOwner: one2one('MessagingMenu', {
messagingMenuOwner: one('MessagingMenu', {
inverse: 'notificationListView',
readonly: true,
}),
notificationGroupViews: one2many('NotificationGroupView', {
notificationGroupViews: many('NotificationGroupView', {
compute: '_computeNotificationGroupViews',
inverse: 'notificationListViewOwner',
isCausal: true,
}),
notificationRequestView: one2one('NotificationRequestView', {
notificationRequestView: one('NotificationRequestView', {
compute: '_computeNotificationRequestView',
inverse: 'notificationListViewOwner',
isCausal: true,
}),
notificationViews: one2many('Model', {
notificationViews: many('Model', {
compute: '_computeNotificationViews',
isCausal: true,
}),
threadNeedactionPreviewViews: one2many('ThreadNeedactionPreviewView', {
threadNeedactionPreviewViews: many('ThreadNeedactionPreviewView', {
compute: '_computeThreadNeedactionPreviewViews',
inverse: 'notificationListViewOwner',
isCausal: true,
}),
threadPreviewViews: one2many('ThreadPreviewView', {
threadPreviewViews: many('ThreadPreviewView', {
compute: '_computeThreadPreviewViews',
inverse: 'notificationListViewOwner',
isCausal: true,
@@ -1,11 +1,11 @@
/** @odoo-module **/
import { addFields, patchIdentifyingFields, patchRecordMethods } from '@mail/model/model_core';
import { one2one } from '@mail/model/model_field';
import { one } from '@mail/model/model_field';
import '@mail/models/notification_list_view/notification_list_view'; // ensure the model definition is loaded before the patch
addFields('NotificationListView', {
qunitTestOwner: one2one('QUnitTest', {
qunitTestOwner: one('QUnitTest', {
inverse: 'notificationListView',
readonly: true,
}),
@@ -1,13 +1,13 @@
/** @odoo-module **/
import { registerModel } from '@mail/model/model_core';
import { one2one } from '@mail/model/model_field';
import { one } from '@mail/model/model_field';
registerModel({
name: 'NotificationRequestView',
identifyingFields: ['notificationListViewOwner'],
fields: {
notificationListViewOwner: one2one('NotificationListView', {
notificationListViewOwner: one('NotificationListView', {
inverse: 'notificationRequestView',
required: true,
readonly: true,
@@ -1,7 +1,7 @@
/** @odoo-module **/
import { registerModel } from '@mail/model/model_core';
import { attr, many2many, many2one, one2many, one2one } from '@mail/model/model_field';
import { attr, many, one } from '@mail/model/model_field';
import { insert, link, unlinkAll } from '@mail/model/model_field_command';
import { cleanSearchTerm } from '@mail/utils/utils';
@@ -406,7 +406,7 @@ registerModel({
avatarUrl: attr({
compute: '_computeAvatarUrl',
}),
country: many2one('Country'),
country: one('Country'),
/**
* Deprecated.
* States the `display_name` of this partner, as returned by the server.
@@ -439,7 +439,7 @@ registerModel({
isOnline: attr({
compute: '_computeIsOnline',
}),
memberThreads: many2many('Thread', {
memberThreads: many('Thread', {
inverse: 'members',
}),
model: attr({
@@ -449,13 +449,13 @@ registerModel({
nameOrDisplayName: attr({
compute: '_computeNameOrDisplayName',
}),
rtcSessions: one2many('RtcSession', {
rtcSessions: many('RtcSession', {
inverse: 'partner',
}),
user: one2one('User', {
user: one('User', {
inverse: 'partner',
}),
volumeSetting: one2one('VolumeSetting', {
volumeSetting: one('VolumeSetting', {
inverse: 'partner',
}),
},
@@ -1,7 +1,7 @@
/** @odoo-module **/
import { registerModel } from '@mail/model/model_core';
import { attr, one2one } from '@mail/model/model_field';
import { attr, one } from '@mail/model/model_field';
import { clear, insertAndReplace, replace } from '@mail/model/model_field_command';
const { Ref } = owl;
@@ -152,7 +152,7 @@ registerModel({
/**
* The record that represents the content inside the popover view.
*/
channelInvitationForm: one2one('ChannelInvitationForm', {
channelInvitationForm: one('ChannelInvitationForm', {
compute: '_computeChannelInvitationForm',
inverse: 'popoverViewOwner',
isCausal: true,
@@ -165,14 +165,14 @@ registerModel({
/**
* If set, this popover view is owned by a composer view.
*/
composerViewOwnerAsEmoji: one2one('ComposerView', {
composerViewOwnerAsEmoji: one('ComposerView', {
inverse: 'emojisPopoverView',
readonly: true,
}),
/**
* Determines the record that is content of this popover view.
*/
content: one2one('Model', {
content: one('Model', {
compute: '_computeContent',
required: true,
}),
@@ -195,7 +195,7 @@ registerModel({
/**
* If set, the content of this popover view is a list of emojis.
*/
emojiListView: one2one('EmojiListView', {
emojiListView: one('EmojiListView', {
compute: '_computeEmojiListView',
inverse: 'popoverViewOwner',
isCausal: true,
@@ -204,7 +204,7 @@ registerModel({
/**
* If set, this popover view is owned by a message action list.
*/
messageActionListOwnerAsReaction: one2one('MessageActionList', {
messageActionListOwnerAsReaction: one('MessageActionList', {
inverse: 'reactionPopoverView',
readonly: true,
}),
@@ -219,7 +219,7 @@ registerModel({
/**
* If set, this popover view is owned by a thread view topbar record.
*/
threadViewTopbarOwnerAsInvite: one2one('ThreadViewTopbar', {
threadViewTopbarOwnerAsInvite: one('ThreadViewTopbar', {
inverse: 'invitePopoverView',
readonly: true,
}),
+4 -4
View File
@@ -3,7 +3,7 @@
import { browser } from "@web/core/browser/browser";
import { registerModel } from '@mail/model/model_core';
import { attr, one2many, one2one } from '@mail/model/model_field';
import { attr, many, one } from '@mail/model/model_field';
import { clear, insert, unlink } from '@mail/model/model_field_command';
import { monitorAudio } from '@mail/utils/media_monitoring/media_monitoring';
@@ -1201,13 +1201,13 @@ registerModel({
/**
* The channel that is hosting the current RTC call.
*/
channel: one2one('Thread', {
channel: one('Thread', {
inverse: 'rtc',
}),
/**
* String, peerToken of the current session used to identify him during the peer-to-peer transactions.
*/
currentRtcSession: one2one('RtcSession', {
currentRtcSession: one('RtcSession', {
inverse: 'rtc',
}),
/**
@@ -1249,7 +1249,7 @@ registerModel({
logs: attr({
default: {},
}),
peerNotificationsToSend: one2many('RtcPeerNotification', {
peerNotificationsToSend: many('RtcPeerNotification', {
isCausal: true,
}),
/**
@@ -1,7 +1,7 @@
/** @odoo-module **/
import { registerModel } from '@mail/model/model_core';
import { attr, many2one, one2one } from '@mail/model/model_field';
import { attr, one } from '@mail/model/model_field';
import { isEventHandled, markEventHandled } from '@mail/utils/utils';
registerModel({
@@ -115,17 +115,17 @@ registerModel({
/**
* The channel of the call.
*/
channel: many2one('Thread', {
channel: one('Thread', {
required: true,
}),
/**
* If set, this card represents an invitation of this guest to this call.
*/
invitedGuest: many2one('Guest'),
invitedGuest: one('Guest'),
/**
* If set, this card represents an invitation of this partner to this call.
*/
invitedPartner: many2one('Partner'),
invitedPartner: one('Partner'),
/**
* States whether this card is representing a person with a pending
* invitation.
@@ -164,18 +164,18 @@ registerModel({
/**
* The callViewer for which this card is the spotlight.
*/
rtcCallViewerOfMainCard: one2one('RtcCallViewer', {
rtcCallViewerOfMainCard: one('RtcCallViewer', {
inverse: 'mainParticipantCard',
}),
/**
* The callViewer for which this card is one of the tiles.
*/
rtcCallViewerOfTile: many2one('RtcCallViewer', {
rtcCallViewerOfTile: one('RtcCallViewer', {
inverse: 'tileParticipantCards',
}),
/**
* If set, this card represents a rtcSession.
*/
rtcSession: many2one('RtcSession'),
rtcSession: one('RtcSession'),
},
});
@@ -3,7 +3,7 @@
import { browser } from "@web/core/browser/browser";
import { registerModel } from '@mail/model/model_core';
import { attr, one2one, one2many } from '@mail/model/model_field';
import { attr, many, one } from '@mail/model/model_field';
import { OnChange } from '@mail/model/model_onchange';
import { clear, insert, insertAndReplace, link, unlink } from '@mail/model/model_field_command';
@@ -350,14 +350,14 @@ registerModel({
/**
* If set, the card to be displayed as the "main/spotlight" card.
*/
mainParticipantCard: one2one('RtcCallParticipantCard', {
mainParticipantCard: one('RtcCallParticipantCard', {
compute: '_computeMainParticipantCard',
inverse: 'rtcCallViewerOfMainCard',
}),
/**
* The model for the controller (buttons).
*/
rtcController: one2one('RtcController', {
rtcController: one('RtcController', {
default: insertAndReplace(),
readonly: true,
inverse: 'callViewer',
@@ -366,7 +366,7 @@ registerModel({
/**
* The model for the menu to control the layout of the viewer.
*/
rtcLayoutMenu: one2one('RtcLayoutMenu', {
rtcLayoutMenu: one('RtcLayoutMenu', {
inverse: 'callViewer',
isCausal: true,
}),
@@ -385,7 +385,7 @@ registerModel({
/**
* ThreadView on which the call viewer is attached.
*/
threadView: one2one('ThreadView', {
threadView: one('ThreadView', {
inverse: 'rtcCallViewer',
readonly: true,
required: true,
@@ -393,7 +393,7 @@ registerModel({
/**
* List of all participant cards (can either be invitations or rtcSessions).
*/
tileParticipantCards: one2many('RtcCallParticipantCard', {
tileParticipantCards: many('RtcCallParticipantCard', {
compute: '_computeTileParticipantCards',
inverse: 'rtcCallViewerOfTile',
}),
@@ -3,7 +3,7 @@
import { browser } from "@web/core/browser/browser";
import { registerModel } from '@mail/model/model_core';
import { attr, one2one } from '@mail/model/model_field';
import { attr, one } from '@mail/model/model_field';
registerModel({
name: 'RtcConfigurationMenu',
@@ -82,7 +82,7 @@ registerModel({
isRegisteringKey: attr({
default: false,
}),
userSetting: one2one('UserSetting', {
userSetting: one('UserSetting', {
inverse: 'rtcConfigurationMenu',
readonly: true,
}),
@@ -1,7 +1,7 @@
/** @odoo-module **/
import { registerModel } from '@mail/model/model_core';
import { attr, one2one } from '@mail/model/model_field';
import { attr, one } from '@mail/model/model_field';
import { insertAndReplace } from '@mail/model/model_field_command';
registerModel({
@@ -82,7 +82,7 @@ registerModel({
},
},
fields: {
callViewer: one2one('RtcCallViewer', {
callViewer: one('RtcCallViewer', {
inverse: 'rtcController',
readonly: true,
required: true,
@@ -90,7 +90,7 @@ registerModel({
isSmall: attr({
compute: '_computeIsSmall',
}),
rtcOptionList: one2one('RtcOptionList', {
rtcOptionList: one('RtcOptionList', {
default: insertAndReplace(),
inverse: 'rtcController',
isCausal: true,
@@ -1,7 +1,7 @@
/** @odoo-module **/
import { registerModel } from '@mail/model/model_core';
import { attr, one2one } from '@mail/model/model_field';
import { attr, one } from '@mail/model/model_field';
import { clear } from '@mail/model/model_field_command';
registerModel({
@@ -42,7 +42,7 @@ registerModel({
},
fields: {
component: attr(),
callViewer: one2one('RtcCallViewer', {
callViewer: one('RtcCallViewer', {
inverse: 'rtcLayoutMenu',
readonly: true,
}),
@@ -1,7 +1,7 @@
/** @odoo-module **/
import { registerModel } from '@mail/model/model_core';
import { attr, one2one } from '@mail/model/model_field';
import { attr, one } from '@mail/model/model_field';
registerModel({
name: 'RtcOptionList',
@@ -61,7 +61,7 @@ registerModel({
* States the OWL component of this option list.
*/
component: attr(),
rtcController: one2one('RtcController', {
rtcController: one('RtcController', {
inverse: 'rtcOptionList',
readonly: true,
required: true,
@@ -3,7 +3,7 @@
import { browser } from "@web/core/browser/browser";
import { registerModel } from '@mail/model/model_core';
import { attr, many2one, one2one, one2many } from '@mail/model/model_field';
import { attr, many, one } from '@mail/model/model_field';
import { clear } from '@mail/model/model_field_command';
registerModel({
@@ -293,7 +293,7 @@ registerModel({
* The mail.channel of the session, rtc sessions are part and managed by
* mail.channel
*/
channel: many2one('Thread', {
channel: one('Thread', {
inverse: 'rtcSessions',
}),
/**
@@ -303,7 +303,7 @@ registerModel({
connectionState: attr({
default: 'Waiting for the peer to send a RTC offer',
}),
guest: many2one('Guest', {
guest: one('Guest', {
inverse: 'rtcSessions',
}),
/**
@@ -318,7 +318,7 @@ registerModel({
* this serves as an explicit inverse as it seems to confuse it with
* other session-channel relations otherwise.
*/
calledChannels: one2many('Thread', {
calledChannels: many('Thread', {
inverse: 'rtcInvitingSession',
}),
/**
@@ -390,7 +390,7 @@ registerModel({
* has open sessions in multiple channels, but only one session per
* channel is allowed.
*/
partner: many2one('Partner', {
partner: one('Partner', {
inverse: 'rtcSessions',
}),
/**
@@ -406,7 +406,7 @@ registerModel({
* sessions from other channels with the same partner (sessions opened from different
* tabs or devices).
*/
rtc: one2one('Rtc', {
rtc: one('Rtc', {
inverse: 'currentRtcSession',
}),
/**
@@ -1,38 +1,38 @@
/** @odoo-module **/
import { registerModel } from '@mail/model/model_core';
import { one2one } from '@mail/model/model_field';
import { one } from '@mail/model/model_field';
import { insertAndReplace } from '@mail/model/model_field_command';
registerModel({
name: 'SoundEffects',
identifyingFields: ['messaging'],
fields: {
channelJoin: one2one('SoundEffect', {
channelJoin: one('SoundEffect', {
default: insertAndReplace({ filename: 'channel_01_in' }),
isCausal: true,
}),
channelLeave: one2one('SoundEffect', {
channelLeave: one('SoundEffect', {
default: insertAndReplace({ filename: 'channel_04_out' }),
isCausal: true,
}),
incomingCall: one2one('SoundEffect', {
incomingCall: one('SoundEffect', {
default: insertAndReplace({ filename: 'call_02_in_' }),
isCausal: true,
}),
memberLeave: one2one('SoundEffect', {
memberLeave: one('SoundEffect', {
default: insertAndReplace({ filename: 'channel_01_out' }),
isCausal: true,
}),
newMessage: one2one('SoundEffect', {
newMessage: one('SoundEffect', {
default: insertAndReplace({ filename: 'dm_02' }),
isCausal: true,
}),
pushToTalk: one2one('SoundEffect', {
pushToTalk: one('SoundEffect', {
default: insertAndReplace({ filename: 'dm_01' }),
isCausal: true,
}),
screenSharing: one2one('SoundEffect', {
screenSharing: one('SoundEffect', {
default: insertAndReplace({ filename: 'share_02' }),
isCausal: true,
}),
@@ -1,7 +1,7 @@
/** @odoo-module **/
import { registerModel } from '@mail/model/model_core';
import { attr, many2one } from '@mail/model/model_field';
import { attr, one } from '@mail/model/model_field';
registerModel({
name: 'SuggestedRecipientInfo',
@@ -65,7 +65,7 @@ registerModel({
/**
* Determines the optional `Partner` associated to `this`.
*/
partner: many2one('Partner'),
partner: one('Partner'),
/**
* Determines why `this` is a suggestion for `this.thread`. It serves as
* visual clue when displaying `this`.
@@ -74,7 +74,7 @@ registerModel({
/**
* Determines the `Thread` concerned by `this.`
*/
thread: many2one('Thread', {
thread: one('Thread', {
inverse: 'suggestedRecipientInfoList',
required: true,
}),
+49 -49
View File
@@ -1,7 +1,7 @@
/** @odoo-module **/
import { registerModel } from '@mail/model/model_core';
import { attr, many2many, many2one, one2many, one2one } from '@mail/model/model_field';
import { attr, many, one } from '@mail/model/model_field';
import { clear, insert, insertAndReplace, link, replace, unlink, unlinkAll } from '@mail/model/model_field_command';
import { OnChange } from '@mail/model/model_onchange';
import throttle from '@mail/utils/throttle/throttle';
@@ -1913,10 +1913,10 @@ registerModel({
* Determines the `mail.activity` that belong to `this`, assuming `this`
* has activities (@see hasActivities).
*/
activities: one2many('Activity', {
activities: many('Activity', {
inverse: 'thread',
}),
allAttachments: many2many('Attachment', {
allAttachments: many('Attachment', {
compute: '_computeAllAttachments',
}),
areAttachmentsLoaded: attr({
@@ -1929,7 +1929,7 @@ registerModel({
areFollowersLoaded: attr({
default: false,
}),
attachments: many2many('Attachment', {
attachments: many('Attachment', {
inverse: 'threads',
}),
/**
@@ -1937,7 +1937,7 @@ registerModel({
* It only makes sense for channels.
*/
avatarCacheKey: attr(),
cache: one2one('ThreadCache', {
cache: one('ThreadCache', {
default: insertAndReplace(),
inverse: 'thread',
isCausal: true,
@@ -1948,26 +1948,26 @@ registerModel({
/**
* States the chat window related to this thread (if any).
*/
chatWindow: one2one('ChatWindow', {
chatWindow: one('ChatWindow', {
inverse: 'thread',
isCausal: true,
}),
/**
* Determines the composer state of this thread.
*/
composer: one2one('Composer', {
composer: one('Composer', {
compute: '_computeComposer',
inverse: 'thread',
isCausal: true,
readonly: true,
}),
correspondent: many2one('Partner', {
correspondent: one('Partner', {
compute: '_computeCorrespondent',
}),
counter: attr({
default: 0,
}),
creator: many2one('User'),
creator: one('User'),
custom_channel_name: attr(),
/**
* Determines the default display mode of this channel. Should contain
@@ -1983,7 +1983,7 @@ registerModel({
* Determines the discuss sidebar category item that displays this
* thread (if any). Only applies to channels.
*/
discussSidebarCategoryItem: one2one('DiscussSidebarCategoryItem', {
discussSidebarCategoryItem: one('DiscussSidebarCategoryItem', {
compute: '_computeDiscussSidebarCategoryItem',
inverse: 'channel',
isCausal: true,
@@ -1998,23 +1998,23 @@ registerModel({
fetchMessagesUrl: attr({
compute: '_computeFetchMessagesUrl',
}),
followersPartner: many2many('Partner', {
followersPartner: many('Partner', {
related: 'followers.partner',
}),
followers: one2many('Follower', {
followers: many('Follower', {
inverse: 'followedThread',
}),
/**
* States the `Activity` that belongs to `this` and that are
* planned in the future (due later than today).
*/
futureActivities: one2many('Activity', {
futureActivities: many('Activity', {
compute: '_computeFutureActivities',
}),
group_based_subscription: attr({
default: false,
}),
guestMembers: many2many('Guest'),
guestMembers: many('Guest'),
/**
* States whether `this` has activities (`mail.activity.mixin` server side).
*/
@@ -2061,11 +2061,11 @@ registerModel({
* FIXME should be simplified if we have the mail.channel.partner model
* in which case the two following fields should be a single relation to that model.
*/
invitedGuests: many2many('Guest'),
invitedGuests: many('Guest'),
/**
* List of partners that have been invited to the RTC call of this channel.
*/
invitedPartners: many2many('Partner'),
invitedPartners: many('Partner'),
/**
* Determines whether this description can be changed.
* Only makes sense for channels.
@@ -2137,25 +2137,25 @@ registerModel({
* pinning, and new message posted. It is contained as a Date object.
*/
lastInterestDateTime: attr(),
lastCurrentPartnerMessageSeenByEveryone: many2one('Message', {
lastCurrentPartnerMessageSeenByEveryone: one('Message', {
compute: '_computeLastCurrentPartnerMessageSeenByEveryone',
}),
/**
* Last message of the thread, could be a transient one.
*/
lastMessage: many2one('Message', {
lastMessage: one('Message', {
compute: '_computeLastMessage',
}),
/**
* States the last known needaction message having this thread as origin.
*/
lastNeedactionMessageAsOriginThread: many2one('Message', {
lastNeedactionMessageAsOriginThread: one('Message', {
compute: '_computeLastNeedactionMessageAsOriginThread',
}),
/**
* Last non-transient message.
*/
lastNonTransientMessage: many2one('Message', {
lastNonTransientMessage: one('Message', {
compute: '_computeLastNonTransientMessage',
}),
/**
@@ -2182,24 +2182,24 @@ registerModel({
* Only makes sense if this thread is a channel.
*/
memberCount: attr(),
members: many2many('Partner', {
members: many('Partner', {
inverse: 'memberThreads',
}),
/**
* Determines the last mentioned channels of the last composer related
* to this thread. Useful to sync the composer when re-creating it.
*/
mentionedChannelsBackup: many2many('Thread'),
mentionedChannelsBackup: many('Thread'),
/**
* Determines the last mentioned partners of the last composer related
* to this thread. Useful to sync the composer when re-creating it.
*/
mentionedPartnersBackup: many2many('Partner'),
mentionedPartnersBackup: many('Partner'),
/**
* Determines the message before which the "new message" separator must
* be positioned, if any.
*/
messageAfterNewMessageSeparator: many2one('Message', {
messageAfterNewMessageSeparator: one('Message', {
compute: '_computeMessageAfterNewMessageSeparator',
}),
message_needaction_counter: attr({
@@ -2210,30 +2210,30 @@ registerModel({
* Note that this field is automatically computed by inverse
* computed field.
*/
messages: many2many('Message', {
messages: many('Message', {
inverse: 'threads',
readonly: true,
}),
/**
* All messages that have been originally posted in this thread.
*/
messagesAsOriginThread: one2many('Message', {
messagesAsOriginThread: many('Message', {
inverse: 'originThread',
isCausal: true,
}),
/**
* Contains the message fetched/seen indicators for all messages of this thread.
*/
messageSeenIndicators: one2many('MessageSeenIndicator', {
messageSeenIndicators: many('MessageSeenIndicator', {
inverse: 'thread',
isCausal: true,
}),
messagingAsRingingThread: many2one('Messaging', {
messagingAsRingingThread: one('Messaging', {
compute: '_computeMessagingAsRingingThread',
inverse: 'ringingThreads',
readonly: true,
}),
messagingMenuAsPinnedAndUnreadChannel: many2one('MessagingMenu', {
messagingMenuAsPinnedAndUnreadChannel: one('MessagingMenu', {
compute: '_computeMessagingMenuAsPinnedAndUnreadChannel',
inverse: 'pinnedAndUnreadChannels',
readonly: true,
@@ -2248,38 +2248,38 @@ registerModel({
/**
* States all known needaction messages having this thread as origin.
*/
needactionMessagesAsOriginThread: many2many('Message', {
needactionMessagesAsOriginThread: many('Message', {
compute: '_computeNeedactionMessagesAsOriginThread',
}),
/**
* All offline members ordered like they are displayed.
*/
orderedOfflineMembers: many2many('Partner', {
orderedOfflineMembers: many('Partner', {
compute: '_computeOrderedOfflineMembers',
}),
/**
* All online members ordered like they are displayed.
*/
orderedOnlineMembers: many2many('Partner', {
orderedOnlineMembers: many('Partner', {
compute: '_computeOrderedOnlineMembers',
}),
/**
* All messages ordered like they are displayed.
*/
orderedMessages: many2many('Message', {
orderedMessages: many('Message', {
compute: '_computeOrderedMessages',
}),
/**
* All messages ordered like they are displayed. This field does not
* contain transient messages which are not "real" records.
*/
orderedNonTransientMessages: many2many('Message', {
orderedNonTransientMessages: many('Message', {
compute: '_computeOrderedNonTransientMessages',
}),
/**
* Ordered typing members on this thread, excluding the current partner.
*/
orderedOtherTypingMembers: many2many('Partner', {
orderedOtherTypingMembers: many('Partner', {
compute: '_computeOrderedOtherTypingMembers',
}),
/**
@@ -2287,7 +2287,7 @@ registerModel({
* is currently typing for the longest time. This list includes current
* partner as typer.
*/
orderedTypingMembers: many2many('Partner', {
orderedTypingMembers: many('Partner', {
compute: '_computeOrderedTypingMembers',
}),
/**
@@ -2296,7 +2296,7 @@ registerModel({
orderedTypingMemberLocalIds: attr({
default: [],
}),
originThreadAttachments: one2many('Attachment', {
originThreadAttachments: many('Attachment', {
inverse: 'originThread',
isCausal: true,
}),
@@ -2304,14 +2304,14 @@ registerModel({
* States the `Activity` that belongs to `this` and that are
* overdue (due earlier than today).
*/
overdueActivities: one2many('Activity', {
overdueActivities: many('Activity', {
compute: '_computeOverdueActivities',
}),
/**
* Contains the seen information for all members of the thread.
* FIXME This field should be readonly once task-2336946 is done.
*/
partnerSeenInfos: one2many('ThreadPartnerSeenInfo', {
partnerSeenInfos: many('ThreadPartnerSeenInfo', {
inverse: 'thread',
isCausal: true,
}),
@@ -2325,17 +2325,17 @@ registerModel({
/**
* If set, the current thread is the thread that hosts the current RTC call.
*/
rtc: one2one('Rtc', {
rtc: one('Rtc', {
inverse: 'channel',
}),
/**
* The session that invited the current user, it is only set when the
* invitation is still pending.
*/
rtcInvitingSession: many2one('RtcSession', {
rtcInvitingSession: one('RtcSession', {
inverse: 'calledChannels',
}),
rtcSessions: one2many('RtcSession', {
rtcSessions: many('RtcSession', {
inverse: 'channel',
isCausal: true,
}),
@@ -2358,7 +2358,7 @@ registerModel({
*
* @see localMessageUnreadCounter
*/
serverLastMessage: many2one('Message'),
serverLastMessage: one('Message'),
/**
* Message unread counter coming from server.
*
@@ -2375,7 +2375,7 @@ registerModel({
/**
* Determines the `SuggestedRecipientInfo` concerning `this`.
*/
suggestedRecipientInfoList: one2many('SuggestedRecipientInfo', {
suggestedRecipientInfoList: many('SuggestedRecipientInfo', {
inverse: 'thread',
isCausal: true,
}),
@@ -2407,21 +2407,21 @@ registerModel({
textInputSelectionDirectionBackup: attr({
default: "none",
}),
threadViews: one2many('ThreadView', {
threadViews: many('ThreadView', {
inverse: 'thread',
}),
/**
* States the `Activity` that belongs to `this` and that are due
* specifically today.
*/
todayActivities: one2many('Activity', {
todayActivities: many('Activity', {
compute: '_computeTodayActivities',
}),
threadNeedactionPreviewViews: one2many('ThreadNeedactionPreviewView', {
threadNeedactionPreviewViews: many('ThreadNeedactionPreviewView', {
inverse: 'thread',
isCausal: true,
}),
threadPreviewViews: one2many('ThreadPreviewView', {
threadPreviewViews: many('ThreadPreviewView', {
inverse: 'thread',
isCausal: true,
}),
@@ -2429,7 +2429,7 @@ registerModel({
* Members that are currently typing something in the composer of this
* thread, including current partner.
*/
typingMembers: many2many('Partner'),
typingMembers: many('Partner'),
/**
* Text that represents the status on this thread about typing members.
*/
@@ -1,7 +1,7 @@
/** @odoo-module **/
import { registerModel } from '@mail/model/model_core';
import { attr, many2many, many2one, one2many, one2one } from '@mail/model/model_field';
import { attr, many, one } from '@mail/model/model_field';
import { link, replace, unlink, unlinkAll } from '@mail/model/model_field_command';
import { OnChange } from '@mail/model/model_onchange';
@@ -314,7 +314,7 @@ registerModel({
* to manage "holes" in message list, while still allowing to display
* new messages on main cache of thread in real-time.
*/
fetchedMessages: many2many('Message', {
fetchedMessages: many('Message', {
compute: '_computeFetchedMessages',
}),
/**
@@ -367,16 +367,16 @@ registerModel({
* cache (@see lastMessage field for that). @see fetchedMessages field
* for a deeper explanation about "fetched" messages.
*/
lastFetchedMessage: many2one('Message', {
lastFetchedMessage: one('Message', {
compute: '_computeLastFetchedMessage',
}),
lastMessage: many2one('Message', {
lastMessage: one('Message', {
compute: '_computeLastMessage',
}),
/**
* List of messages linked to this cache.
*/
messages: many2many('Message', {
messages: many('Message', {
compute: '_computeMessages',
}),
/**
@@ -386,22 +386,22 @@ registerModel({
* cache (@see orderedMessages field for that). @see fetchedMessages
* field for deeper explanation about "fetched" messages.
*/
orderedFetchedMessages: many2many('Message', {
orderedFetchedMessages: many('Message', {
compute: '_computeOrderedFetchedMessages',
}),
/**
* Ordered list of messages linked to this cache.
*/
orderedMessages: many2many('Message', {
orderedMessages: many('Message', {
compute: '_computeOrderedMessages',
}),
/**
* List of ordered non empty messages linked to this cache.
*/
orderedNonEmptyMessages: many2many('Message', {
orderedNonEmptyMessages: many('Message', {
compute: '_computeOrderedNonEmptyMessages',
}),
thread: one2one('Thread', {
thread: one('Thread', {
inverse: 'cache',
readonly: true,
required: true,
@@ -409,7 +409,7 @@ registerModel({
/**
* States the 'ThreadView' that are currently displaying `this`.
*/
threadViews: one2many('ThreadView', {
threadViews: many('ThreadView', {
inverse: 'threadCache',
}),
},
@@ -1,18 +1,18 @@
/** @odoo-module **/
import { registerModel } from '@mail/model/model_core';
import { many2one } from '@mail/model/model_field';
import { one } from '@mail/model/model_field';
registerModel({
name: 'ThreadNeedactionPreviewView',
identifyingFields: ['notificationListViewOwner', 'thread'],
fields: {
notificationListViewOwner: many2one('NotificationListView', {
notificationListViewOwner: one('NotificationListView', {
inverse: 'threadNeedactionPreviewViews',
readonly: true,
required: true,
}),
thread: many2one('Thread', {
thread: one('Thread', {
inverse: 'threadNeedactionPreviewViews',
readonly: true,
required: true,
@@ -1,25 +1,25 @@
/** @odoo-module **/
import { registerModel } from '@mail/model/model_core';
import { many2one } from '@mail/model/model_field';
import { one } from '@mail/model/model_field';
registerModel({
name: 'ThreadPartnerSeenInfo',
identifyingFields: ['thread', 'partner'],
fields: {
lastFetchedMessage: many2one('Message'),
lastSeenMessage: many2one('Message'),
lastFetchedMessage: one('Message'),
lastSeenMessage: one('Message'),
/**
* Partner that this seen info is related to.
*/
partner: many2one('Partner', {
partner: one('Partner', {
readonly: true,
required: true,
}),
/**
* Thread (channel) that this seen info is related to.
*/
thread: many2one('Thread', {
thread: one('Thread', {
inverse: 'partnerSeenInfos',
readonly: true,
required: true,
@@ -1,18 +1,18 @@
/** @odoo-module **/
import { registerModel } from '@mail/model/model_core';
import { many2one } from '@mail/model/model_field';
import { one } from '@mail/model/model_field';
registerModel({
name: 'ThreadPreviewView',
identifyingFields: ['notificationListViewOwner', 'thread'],
fields: {
notificationListViewOwner: many2one('NotificationListView', {
notificationListViewOwner: one('NotificationListView', {
inverse: 'threadPreviewViews',
readonly: true,
required: true,
}),
thread: many2one('Thread', {
thread: one('Thread', {
inverse: 'threadPreviewViews',
readonly: true,
required: true,
@@ -1,12 +1,12 @@
/** @odoo-module **/
import { addFields, patchIdentifyingFields } from '@mail/model/model_core';
import { one2one } from '@mail/model/model_field';
import { one } from '@mail/model/model_field';
// ensure that the model definition is loaded before the patch
import '@mail/models/thread_view/thread_viewer';
addFields('ThreadViewer', {
qunitTest: one2one('QUnitTest', {
qunitTest: one('QUnitTest', {
inverse: 'threadViewer',
readonly: true,
}),
@@ -2,7 +2,7 @@
import { registerModel } from '@mail/model/model_core';
import { RecordDeletedError } from '@mail/model/model_errors';
import { attr, many2many, many2one, one2many, one2one } from '@mail/model/model_field';
import { attr, many, one } from '@mail/model/model_field';
import { clear, insertAndReplace, link, replace, unlink } from '@mail/model/model_field_command';
import { OnChange } from '@mail/model/model_onchange';
@@ -325,7 +325,7 @@ registerModel({
componentHintList: attr({
default: [],
}),
composerView: one2one('ComposerView', {
composerView: one('ComposerView', {
compute: '_computeComposerView',
inverse: 'threadView',
isCausal: true,
@@ -403,29 +403,29 @@ registerModel({
/**
* Last message in the context of the currently displayed thread cache.
*/
lastMessage: many2one('Message', {
lastMessage: one('Message', {
related: 'thread.lastMessage',
}),
lastMessageView: one2one('MessageView', {
lastMessageView: one('MessageView', {
compute: '_computeLastMessageView',
}),
/**
* Most recent message in this ThreadView that has been shown to the
* current partner in the currently displayed thread cache.
*/
lastVisibleMessage: many2one('Message'),
messageListView: one2one('MessageListView', {
lastVisibleMessage: one('Message'),
messageListView: one('MessageListView', {
compute: '_computeMessageListView',
inverse: 'threadViewOwner',
isCausal: true,
}),
messages: many2many('Message', {
messages: many('Message', {
related: 'threadCache.messages',
}),
/**
* States the message views used to display this messages.
*/
messageViews: one2many('MessageView', {
messageViews: many('MessageView', {
compute: '_computeMessageViews',
inverse: 'threadView',
isCausal: true,
@@ -440,11 +440,11 @@ registerModel({
/**
* Determines the message that's currently being replied to.
*/
replyingToMessageView: many2one('MessageView'),
replyingToMessageView: one('MessageView'),
/**
* Determines the Rtc call viewer of this thread.
*/
rtcCallViewer: one2one('RtcCallViewer', {
rtcCallViewer: one('RtcCallViewer', {
compute: '_computeRtcCallViewer',
inverse: 'threadView',
isCausal: true,
@@ -453,7 +453,7 @@ registerModel({
/**
* Determines the `Thread` currently displayed by `this`.
*/
thread: many2one('Thread', {
thread: one('Thread', {
inverse: 'threadViews',
readonly: true,
related: 'threadViewer.thread',
@@ -461,7 +461,7 @@ registerModel({
/**
* States the `ThreadCache` currently displayed by `this`.
*/
threadCache: many2one('ThreadCache', {
threadCache: one('ThreadCache', {
inverse: 'threadViews',
readonly: true,
related: 'threadViewer.threadCache',
@@ -489,7 +489,7 @@ registerModel({
/**
* Determines the `ThreadViewer` currently managing `this`.
*/
threadViewer: one2one('ThreadViewer', {
threadViewer: one('ThreadViewer', {
inverse: 'threadView',
readonly: true,
required: true,
@@ -497,7 +497,7 @@ registerModel({
/**
* Determines the top bar of this thread view, if any.
*/
topbar: one2one('ThreadViewTopbar', {
topbar: one('ThreadViewTopbar', {
compute: '_computeTopbar',
inverse: 'threadView',
isCausal: true,
@@ -1,7 +1,7 @@
/** @odoo-module **/
import { registerModel } from '@mail/model/model_core';
import { attr, many2one, one2one } from '@mail/model/model_field';
import { attr, one } from '@mail/model/model_field';
import { clear, insertAndReplace } from '@mail/model/model_field_command';
registerModel({
@@ -59,11 +59,11 @@ registerModel({
},
},
fields: {
chatter: one2one('Chatter', {
chatter: one('Chatter', {
inverse: 'threadViewer',
readonly: true,
}),
chatWindow: one2one('ChatWindow', {
chatWindow: one('ChatWindow', {
inverse: 'threadViewer',
readonly: true,
}),
@@ -73,11 +73,11 @@ registerModel({
compact: attr({
default: false,
}),
discuss: one2one('Discuss', {
discuss: one('Discuss', {
inverse: 'threadViewer',
readonly: true,
}),
discussPublicView: one2one('DiscussPublicView', {
discussPublicView: one('DiscussPublicView', {
inverse: 'threadViewer',
readonly: true,
}),
@@ -115,11 +115,11 @@ registerModel({
/**
* Determines the `Thread` that should be displayed by `this`.
*/
thread: many2one('Thread'),
thread: one('Thread'),
/**
* States the `ThreadCache` that should be displayed by `this`.
*/
threadCache: many2one('ThreadCache', {
threadCache: one('ThreadCache', {
related: 'thread.cache',
}),
/**
@@ -144,7 +144,7 @@ registerModel({
/**
* States the `ThreadView` currently displayed and managed by `this`.
*/
threadView: one2one('ThreadView', {
threadView: one('ThreadView', {
compute: '_computeThreadView',
inverse: 'threadViewer',
isCausal: true,
@@ -1,7 +1,7 @@
/** @odoo-module **/
import { registerModel } from '@mail/model/model_core';
import { attr, many2one, one2one } from '@mail/model/model_field';
import { attr, one } from '@mail/model/model_field';
import { clear, insertAndReplace } from '@mail/model/model_field_command';
registerModel({
@@ -564,7 +564,7 @@ registerModel({
* If set, this is the record of invite button popover that is currently
* open in the topbar.
*/
invitePopoverView: one2one('PopoverView', {
invitePopoverView: one('PopoverView', {
isCausal: true,
inverse: 'threadViewTopbarOwnerAsInvite',
}),
@@ -631,7 +631,7 @@ registerModel({
/**
* States the thread that is displayed by this top bar.
*/
thread: many2one('Thread', {
thread: one('Thread', {
related: 'threadView.thread',
}),
/**
@@ -647,7 +647,7 @@ registerModel({
/**
* States the thread view managing this top bar.
*/
threadView: one2one('ThreadView', {
threadView: one('ThreadView', {
inverse: 'topbar',
readonly: true,
required: true,
+2 -2
View File
@@ -1,7 +1,7 @@
/** @odoo-module **/
import { registerModel } from '@mail/model/model_core';
import { attr, one2one } from '@mail/model/model_field';
import { attr, one } from '@mail/model/model_field';
import { insert, unlink } from '@mail/model/model_field_command';
registerModel({
@@ -187,7 +187,7 @@ registerModel({
nameOrDisplayName: attr({
compute: '_computeNameOrDisplayName',
}),
partner: one2one('Partner', {
partner: one('Partner', {
inverse: 'user',
}),
/**
@@ -3,7 +3,7 @@
import { browser } from "@web/core/browser/browser";
import { registerModel } from '@mail/model/model_core';
import { attr, one2one, one2many } from '@mail/model/model_field';
import { attr, many, one } from '@mail/model/model_field';
import { insertAndReplace } from '@mail/model/model_field_command';
registerModel({
@@ -251,7 +251,7 @@ registerModel({
/**
* Model for the component with the controls for RTC related settings.
*/
rtcConfigurationMenu: one2one('RtcConfigurationMenu', {
rtcConfigurationMenu: one('RtcConfigurationMenu', {
default: insertAndReplace(),
inverse: 'userSetting',
isCausal: true,
@@ -284,7 +284,7 @@ registerModel({
/**
* Determines the volume chosen by the current user for each other user.
*/
volumeSettings: one2many('VolumeSetting', {
volumeSettings: many('VolumeSetting', {
inverse: 'userSetting',
isCausal: true,
}),
@@ -1,7 +1,7 @@
/** @odoo-module **/
import { registerModel } from '@mail/model/model_core';
import { attr, one2one, many2one } from '@mail/model/model_field';
import { attr, one } from '@mail/model/model_field';
import { OnChange } from '@mail/model/model_onchange';
registerModel({
@@ -28,17 +28,17 @@ registerModel({
},
},
fields: {
guest: one2one('Guest', {
guest: one('Guest', {
inverse: 'volumeSetting',
}),
id: attr({
readonly: true,
required: true,
}),
partner: one2one('Partner', {
partner: one('Partner', {
inverse: 'volumeSetting',
}),
userSetting: many2one('UserSetting', {
userSetting: one('UserSetting', {
inverse: 'volumeSettings',
required: true,
}),
@@ -1,7 +1,7 @@
/** @odoo-module **/
import { registerModel } from '@mail/model/model_core';
import { attr, one2one } from '@mail/model/model_field';
import { attr, one } from '@mail/model/model_field';
import { clear, insertAndReplace } from '@mail/model/model_field_command';
const getNextGuestNameInputId = (function () {
@@ -128,14 +128,14 @@ registerModel({
* States the channel to redirect to once the user clicks on the
* 'joinButton'.
*/
channel: one2one('Thread', {
channel: one('Thread', {
readonly: true,
required: true,
}),
/**
* States discuss public view on which this welcome view is displayed.
*/
discussPublicView: one2one('DiscussPublicView', {
discussPublicView: one('DiscussPublicView', {
inverse: 'welcomeView',
readonly: true,
required: true,
@@ -182,7 +182,7 @@ registerModel({
/**
* States the media preview embedded in this welcome view.
*/
mediaPreview: one2one('MediaPreview', {
mediaPreview: one('MediaPreview', {
compute: '_computeMediaPreview',
inverse: 'welcomeView',
isCausal: true,
+6 -6
View File
@@ -1,28 +1,28 @@
/** @odoo-module **/
import { registerModel } from '@mail/model/model_core';
import { one2one } from '@mail/model/model_field';
import { one } from '@mail/model/model_field';
registerModel({
name: 'QUnitTest',
identifyingFields: [], // singleton acceptable (only one test at a time)
fields: {
composer: one2one('Composer', {
composer: one('Composer', {
isCausal: true,
}),
composerView: one2one('ComposerView', {
composerView: one('ComposerView', {
inverse: 'qunitTest',
isCausal: true,
}),
messageView: one2one('MessageView', {
messageView: one('MessageView', {
inverse: 'qunitTest',
isCausal: true,
}),
notificationListView: one2one('NotificationListView', {
notificationListView: one('NotificationListView', {
inverse: 'qunitTestOwner',
isCausal: true,
}),
threadViewer: one2one('ThreadViewer', {
threadViewer: one('ThreadViewer', {
inverse: 'qunitTest',
isCausal: true,
}),
@@ -1,7 +1,7 @@
/** @odoo-module **/
import { addFields, patchModelMethods } from '@mail/model/model_core';
import { many2one } from '@mail/model/model_field';
import { one } from '@mail/model/model_field';
import { insert, unlink } from '@mail/model/model_field_command';
// ensure that the model definition is loaded before the patch
import '@mail/models/thread/thread';
@@ -27,7 +27,7 @@ addFields('Thread', {
/**
* Visitor connected to the livechat.
*/
visitor: many2one('Visitor', {
visitor: one('Visitor', {
inverse: 'threads',
}),
});
@@ -1,7 +1,7 @@
/** @odoo-module **/
import { registerModel } from '@mail/model/model_core';
import { attr, many2one, one2many } from '@mail/model/model_field';
import { attr, many, one } from '@mail/model/model_field';
import { insert, link, unlink } from '@mail/model/model_field_command';
registerModel({
@@ -93,7 +93,7 @@ registerModel({
/**
* Country of the visitor.
*/
country: many2one('Country', {
country: one('Country', {
compute: '_computeCountry',
}),
/**
@@ -125,11 +125,11 @@ registerModel({
/**
* Partner linked to this visitor, if any.
*/
partner: many2one('Partner'),
partner: one('Partner'),
/**
* Threads with this visitor as member
*/
threads: one2many('Thread', {
threads: many('Thread', {
inverse: 'visitor',
}),
/**