Model patches are now defined using the `registerPatch` function. This
function takes an object as argument which keys match those of a model
definition.
Benefits:
+ More consistent shape between model definitions and patch definitions
+ No need to import one function to each type of patch
+ No need to repeat the model name for each type of patch
+ No need to import the original definition
Task-2998282.
* = calendar, crm, hr, im_livechat, note, rating, sms, snailmail,
website_livechat, website_slides
closes odoo/odoo#101827
X-original-commit: 7d23491b44b7372209057ea2abc565a95710b316
Related: odoo/enterprise#32136
Signed-off-by: Sébastien Theys (seb) <seb@odoo.com>
Signed-off-by: Louis Wicket (wil) <wil@odoo.com>
30 lines
724 B
JavaScript
30 lines
724 B
JavaScript
/** @odoo-module **/
|
|
|
|
import { registerPatch } from '@mail/model/model_core';
|
|
import { one } from '@mail/model/model_field';
|
|
|
|
registerPatch({
|
|
name: 'Timer',
|
|
fields: {
|
|
duration: {
|
|
compute() {
|
|
if (this.qunitTestOwner1) {
|
|
return 0;
|
|
}
|
|
if (this.qunitTestOwner2) {
|
|
return 1000 * 1000;
|
|
}
|
|
return this._super();
|
|
},
|
|
},
|
|
qunitTestOwner1: one('QUnitTest', {
|
|
identifying: true,
|
|
inverse: 'timer1',
|
|
}),
|
|
qunitTestOwner2: one('QUnitTest', {
|
|
identifying: true,
|
|
inverse: 'timer2',
|
|
}),
|
|
},
|
|
});
|