Files
odoo_source/addons/mail/static/tests/models/throttle_qunit_tests.js
T
Alexandre Kühn 669dccddd9 [IMP] mail: introduce Throttle model
Task-2831082

closes odoo/odoo#91502

Signed-off-by: Sébastien Theys (seb) <seb@odoo.com>
2022-06-01 15:22:59 +02:00

35 lines
895 B
JavaScript

/** @odoo-module **/
import { addFields, patchIdentifyingFields, patchRecordMethods } from '@mail/model/model_core';
import { one } from '@mail/model/model_field';
// ensure that the model definition is loaded before the patch
import '@mail/models/throttle';
addFields('Throttle', {
qunitTestOwner1: one('QUnitTest', {
inverse: 'throttle1',
readonly: true,
}),
qunitTestOwner2: one('QUnitTest', {
inverse: 'throttle2',
readonly: true,
}),
});
patchIdentifyingFields('Throttle', identifyingFields => {
identifyingFields[0].push('qunitTestOwner1');
identifyingFields[0].push('qunitTestOwner2');
});
patchRecordMethods('Throttle', {
_computeDuration() {
if (this.qunitTestOwner1) {
return 0;
}
if (this.qunitTestOwner2) {
return 1000;
}
return this._super();
},
});