From 93cf24f73ae79cdfd0346145d0b828ebd1ea07f9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?G=C3=A9ry=20Debongnie?= Date: Wed, 13 Sep 2017 11:48:02 +0200 Subject: [FIX] web: reimplement custom widgets in basic views With the new views, we lost a (almost unused and undocumented) feature: the ability to instantiate custom widgets in a form view, not linked to a particular field. For example: We reintroduce this feature in this commit, with a nice twist: it also works for the list view and the kanban view. --- .../static/src/js/views/basic/widget_registry.js | 27 ++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 addons/web/static/src/js/views/basic/widget_registry.js (limited to 'addons/web/static/src/js/views/basic/widget_registry.js') diff --git a/addons/web/static/src/js/views/basic/widget_registry.js b/addons/web/static/src/js/views/basic/widget_registry.js new file mode 100644 index 00000000000..470127bd12e --- /dev/null +++ b/addons/web/static/src/js/views/basic/widget_registry.js @@ -0,0 +1,27 @@ +odoo.define('web.widget_registry', function (require) { + "use strict"; + + // This registry is supposed to contain all custom widgets that will be + // available in the basic views, with the tag . There are + // currently no such widget in the web client, but the functionality is + // certainly useful to be able to cleanly add custom behaviour in basic + // views (and most notably, the form view) + // + // The way custom widgets work is that they register themselves to this + // registry: + // + // widgetRegistry.add('some_name', MyWidget); + // + // Then, they are available with the tag (in the arch): + // + // + // + // Widgets will be then properly instantiated, rendered and destroyed at the + // appropriate time, with the current state in second argument. + // + // For more examples, look at the tests (grep '