summaryrefslogtreecommitdiff
path: root/addons/web/static/tests/views/form_tests.js
diff options
context:
space:
mode:
authorMichael Mattiello (mcm) <mcm@odoo.com>2020-08-03 13:24:14 +0000
committerMichael Mattiello (mcm) <mcm@odoo.com>2020-08-05 11:54:42 +0000
commitfaab9ee9f6dd9ef8afba51151de32fdb69db1fd6 (patch)
treeb875f66b3aa6950dd68d59041720ddf0102eb34e /addons/web/static/tests/views/form_tests.js
parentf1bbc282f8f490bca501426a502ae0f13669c530 (diff)
[FIX] web: form: prevent from calling mounted twice
With this commit, the FormRenderer no longer directly extends the WidgetAdapterMixin. It doesn't need to as its parent class (the BasicRenderer) already uses it. Worse, they both called WidgetAdapterMixin.on_attach_callback, and thus mounted was called twice on Components in form views. closes odoo/odoo#55401 X-original-commit: 4c627abd310a131a4828e9ee6be451aeee4708db Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
Diffstat (limited to 'addons/web/static/tests/views/form_tests.js')
-rw-r--r--addons/web/static/tests/views/form_tests.js29
1 files changed, 29 insertions, 0 deletions
diff --git a/addons/web/static/tests/views/form_tests.js b/addons/web/static/tests/views/form_tests.js
index 5033c990c43..edc96a05e71 100644
--- a/addons/web/static/tests/views/form_tests.js
+++ b/addons/web/static/tests/views/form_tests.js
@@ -6,6 +6,7 @@ var BasicModel = require('web.BasicModel');
var concurrency = require('web.concurrency');
var core = require('web.core');
var fieldRegistry = require('web.field_registry');
+const fieldRegistryOwl = require('web.field_registry_owl');
var FormView = require('web.FormView');
var mixins = require('web.mixins');
var NotificationService = require('web.NotificationService');
@@ -9532,6 +9533,34 @@ QUnit.module('Views', {
form.destroy();
delete widgetRegistry.map.test;
});
+
+ QUnit.test('do not call mounted twice on children', async function (assert) {
+ assert.expect(3);
+
+ class CustomFieldComponent extends fieldRegistryOwl.get('boolean') {
+ mounted() {
+ super.mounted(...arguments);
+ assert.step('mounted');
+ }
+ willUnmount() {
+ super.willUnmount(...arguments);
+ assert.step('willUnmount');
+ }
+ }
+ fieldRegistryOwl.add('custom', CustomFieldComponent);
+
+ const form = await createView({
+ View: FormView,
+ model: 'partner',
+ data: this.data,
+ arch: `<form><field name="bar" widget="custom"/></form>`,
+ });
+
+ form.destroy();
+ delete fieldRegistryOwl.map.custom;
+
+ assert.verifySteps(['mounted', 'willUnmount']);
+ });
});
});