summaryrefslogtreecommitdiff
path: root/addons/web/static/src/js/fields
diff options
context:
space:
mode:
authorMichael Mattiello (mcm) <mcm@odoo.com>2020-03-27 10:56:05 +0000
committerMichael Mattiello (mcm) <mcm@odoo.com>2020-03-31 07:11:01 +0000
commit9324282b0118e311382ee9a57cd10ef3f02d1dbb (patch)
treeb4663f82c2e837ba23f70b562b6dfd743b96167f /addons/web/static/src/js/fields
parent91c7e574ed4a08a4d9998a7f5f481b99ae6154ee (diff)
[REF] web,*: add new field registry for components
* account This commit adds a new field registry for component fields. This field registry is used to only register the new field components and the other one should register the legacy fields. Those two registries will be used together while all legacy fields are not converted to owl component. As the legacy registry now throws an error when adding a component field the existing component fields (account.ShowGroupedList and account.ShowResequenceRenderer) are moved into the new registry. This commit also refactors some field managers (form renderer, list editable renderer, calendar popover) to use the new registry and thus support the component fields. task id: 2193996
Diffstat (limited to 'addons/web/static/src/js/fields')
-rw-r--r--addons/web/static/src/js/fields/field_registry.js11
-rw-r--r--addons/web/static/src/js/fields/field_registry_owl.js31
2 files changed, 41 insertions, 1 deletions
diff --git a/addons/web/static/src/js/fields/field_registry.js b/addons/web/static/src/js/fields/field_registry.js
index 49f1f678304..b8b3fe61452 100644
--- a/addons/web/static/src/js/fields/field_registry.js
+++ b/addons/web/static/src/js/fields/field_registry.js
@@ -3,7 +3,16 @@ odoo.define('web.field_registry', function (require) {
var Registry = require('web.Registry');
-return new Registry();
+var FieldRegistry = Registry.extend({
+ add: function (key, value, score) {
+ if (value.prototype instanceof owl.Component) {
+ throw new Error("This registry should not contain any Component. Use 'web.field_registry_owl' instead.");
+ }
+ return this._super(...arguments);
+ },
+});
+
+return new FieldRegistry();
});
odoo.define('web._field_registry', function (require) {
diff --git a/addons/web/static/src/js/fields/field_registry_owl.js b/addons/web/static/src/js/fields/field_registry_owl.js
new file mode 100644
index 00000000000..f5f7d900ef8
--- /dev/null
+++ b/addons/web/static/src/js/fields/field_registry_owl.js
@@ -0,0 +1,31 @@
+odoo.define('web.field_registry_owl', function (require) {
+ "use strict";
+
+ const Registry = require('web.Registry');
+
+ const FieldRegistry = Registry.extend({
+ add: function (key, value, score) {
+ if (!(value.prototype instanceof owl.Component)) {
+ throw new Error("This registry should only contain subclasses of Component");
+ }
+ return this._super(...arguments);
+ },
+ });
+
+ return new FieldRegistry();
+});
+
+odoo.define('web._field_registry_owl', function (require) {
+ "use strict";
+
+ /**
+ * This module registers field components (specifications of the AbstractField Component)
+ */
+
+ const basicFields = require('web.basic_fields_owl');
+ const registry = require('web.field_registry_owl');
+
+ // Basic fields
+ registry
+ .add('boolean', basicFields.FieldBoolean);
+});