Files
odoo_source/addons/mail/static/tests/models/timer_qunit_tests.js
T
Alexandre Kühn c53ddf00e2 [IMP] mail: convert timer utils into model
Better integration with the rest of the code.

Task-2831082

closes odoo/odoo#90726

Signed-off-by: Sébastien Theys (seb) <seb@odoo.com>
2022-05-16 16:24:47 +02:00

35 lines
884 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/timer';
addFields('Timer', {
qunitTestOwner1: one('QUnitTest', {
inverse: 'timer1',
readonly: true,
}),
qunitTestOwner2: one('QUnitTest', {
inverse: 'timer2',
readonly: true,
}),
});
patchIdentifyingFields('Timer', identifyingFields => {
identifyingFields[0].push('qunitTestOwner1');
identifyingFields[0].push('qunitTestOwner2');
});
patchRecordMethods('Timer', {
_computeDuration() {
if (this.qunitTestOwner1) {
return 0;
}
if (this.qunitTestOwner2) {
return 1000 * 1000;
}
return this._super();
},
});