From 7e2074afefd46a448a5d1ff3e9bad89c82e67c96 Mon Sep 17 00:00:00 2001
From: Alexey Pelykh
Date: Wed, 11 Sep 2019 14:04:03 +0200
Subject: [PATCH 1/7] [ADD] web_widget_dropdown_dynamic
---
web_widget_dropdown_dynamic/__init__.py | 1 +
web_widget_dropdown_dynamic/__manifest__.py | 20 ++
.../readme/CONTRIBUTORS.rst | 1 +
.../readme/DESCRIPTION.rst | 9 +
.../readme/ROADMAP.rst | 1 +
web_widget_dropdown_dynamic/readme/USAGE.rst | 24 +++
.../static/src/js/basic_model.js | 47 +++++
.../static/src/js/field_dynamic_dropdown.js | 140 ++++++++++++++
.../web_widget_dropdown_dynamic_tests.js | 177 ++++++++++++++++++
.../templates/assets.xml | 19 ++
.../__init__.py | 3 +
.../__manifest__.py | 20 ++
.../models/__init__.py | 3 +
.../web_widget_dropdown_dynamic_example.py | 87 +++++++++
.../web_widget_dropdown_dynamic_example.xml | 58 ++++++
15 files changed, 610 insertions(+)
create mode 100644 web_widget_dropdown_dynamic/__init__.py
create mode 100644 web_widget_dropdown_dynamic/__manifest__.py
create mode 100644 web_widget_dropdown_dynamic/readme/CONTRIBUTORS.rst
create mode 100644 web_widget_dropdown_dynamic/readme/DESCRIPTION.rst
create mode 100644 web_widget_dropdown_dynamic/readme/ROADMAP.rst
create mode 100644 web_widget_dropdown_dynamic/readme/USAGE.rst
create mode 100644 web_widget_dropdown_dynamic/static/src/js/basic_model.js
create mode 100644 web_widget_dropdown_dynamic/static/src/js/field_dynamic_dropdown.js
create mode 100644 web_widget_dropdown_dynamic/static/tests/web_widget_dropdown_dynamic_tests.js
create mode 100644 web_widget_dropdown_dynamic/templates/assets.xml
create mode 100644 web_widget_dropdown_dynamic_example/__init__.py
create mode 100644 web_widget_dropdown_dynamic_example/__manifest__.py
create mode 100644 web_widget_dropdown_dynamic_example/models/__init__.py
create mode 100644 web_widget_dropdown_dynamic_example/models/web_widget_dropdown_dynamic_example.py
create mode 100644 web_widget_dropdown_dynamic_example/views/web_widget_dropdown_dynamic_example.xml
diff --git a/web_widget_dropdown_dynamic/__init__.py b/web_widget_dropdown_dynamic/__init__.py
new file mode 100644
index 000000000..c71289ab1
--- /dev/null
+++ b/web_widget_dropdown_dynamic/__init__.py
@@ -0,0 +1 @@
+# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
diff --git a/web_widget_dropdown_dynamic/__manifest__.py b/web_widget_dropdown_dynamic/__manifest__.py
new file mode 100644
index 000000000..8ede2ec51
--- /dev/null
+++ b/web_widget_dropdown_dynamic/__manifest__.py
@@ -0,0 +1,20 @@
+# Copyright 2019 Brainbean Apps (https://brainbeanapps.com)
+# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
+{
+ 'name': 'Dynamic Dropdown Widget',
+ 'summary': 'This module adds support for dynamic dropdown widget',
+ 'category': 'Web',
+ 'version': '12.0.1.0.0',
+ 'license': 'AGPL-3',
+ 'author':
+ 'Brainbean Apps OU, '
+ 'Odoo Community Association (OCA)',
+ 'website': 'https://github.com/OCA/web/',
+ 'depends': [
+ 'web',
+ ],
+ 'data': [
+ 'templates/assets.xml',
+ ],
+ 'installable': True,
+}
diff --git a/web_widget_dropdown_dynamic/readme/CONTRIBUTORS.rst b/web_widget_dropdown_dynamic/readme/CONTRIBUTORS.rst
new file mode 100644
index 000000000..1c6a35a1e
--- /dev/null
+++ b/web_widget_dropdown_dynamic/readme/CONTRIBUTORS.rst
@@ -0,0 +1 @@
+* Alexey Pelykh
diff --git a/web_widget_dropdown_dynamic/readme/DESCRIPTION.rst b/web_widget_dropdown_dynamic/readme/DESCRIPTION.rst
new file mode 100644
index 000000000..1ce39c5f7
--- /dev/null
+++ b/web_widget_dropdown_dynamic/readme/DESCRIPTION.rst
@@ -0,0 +1,9 @@
+Dynamic dropdown widget that supports resolving options from backend of:
+
+ * ``fields.Char``
+ * ``fields.Integer``
+ * ``fields.Selection``
+
+**NOTE:** This widget is not intended to *extend* ``fields.Selection``, but to
+filter selection values. For fully-dynamic set of options, use ``fields.Char``
+instead.
diff --git a/web_widget_dropdown_dynamic/readme/ROADMAP.rst b/web_widget_dropdown_dynamic/readme/ROADMAP.rst
new file mode 100644
index 000000000..7186b62cf
--- /dev/null
+++ b/web_widget_dropdown_dynamic/readme/ROADMAP.rst
@@ -0,0 +1 @@
+ * In v13, ``$.when`` is going to become `Promise.resolve`
diff --git a/web_widget_dropdown_dynamic/readme/USAGE.rst b/web_widget_dropdown_dynamic/readme/USAGE.rst
new file mode 100644
index 000000000..f30491bc4
--- /dev/null
+++ b/web_widget_dropdown_dynamic/readme/USAGE.rst
@@ -0,0 +1,24 @@
+.. code-block:: python
+
+ @api.model
+ def method_name(self):
+ values = [
+ ('value_a', 'Title A'),
+ ]
+ if self.env.context.get('depending_on') == True:
+ values += [
+ ('value_b', 'Title B'),
+ ]
+ return values
+
+.. code-block:: xml
+
+
+
diff --git a/web_widget_dropdown_dynamic/static/src/js/basic_model.js b/web_widget_dropdown_dynamic/static/src/js/basic_model.js
new file mode 100644
index 000000000..a059366ba
--- /dev/null
+++ b/web_widget_dropdown_dynamic/static/src/js/basic_model.js
@@ -0,0 +1,47 @@
+/*
+ * Copyright 2019 Brainbean Apps (https://brainbeanapps.com)
+ * License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
+ */
+odoo.define('web_widget_dropdown_dynamic.basic_model', function (require) {
+ "use strict";
+
+ var BasicModel = require('web.BasicModel');
+
+ BasicModel.include({
+ /**
+ * Fetches all the values associated to the given fieldName.
+ *
+ * @param {Object} record - an element from the localData
+ * @param {Object} fieldName - the name of the field
+ * @param {Object} fieldInfo
+ * @returns {Promise}
+ * The promise is resolved with the fetched special values.
+ * If this data is the same as the previously fetched one
+ * (for the given parameters), no RPC is done and the promise
+ * is resolved with the undefined value.
+ */
+ _fetchDynamicDropdownValues: function (record, fieldName, fieldInfo) {
+ var model = fieldInfo.options.model || record.model;
+ var method = fieldInfo.values || fieldInfo.options.values;
+ if (!method) {
+ return $.when();
+ }
+
+ var context = record.getContext({fieldName: fieldName});
+
+ // avoid rpc if not necessary
+ var hasChanged = this._saveSpecialDataCache(record, fieldName, {
+ context: context,
+ });
+ if (!hasChanged) {
+ return $.when();
+ }
+
+ return this._rpc({
+ model: model,
+ method: method,
+ context: context,
+ });
+ },
+ });
+});
diff --git a/web_widget_dropdown_dynamic/static/src/js/field_dynamic_dropdown.js b/web_widget_dropdown_dynamic/static/src/js/field_dynamic_dropdown.js
new file mode 100644
index 000000000..0a9443127
--- /dev/null
+++ b/web_widget_dropdown_dynamic/static/src/js/field_dynamic_dropdown.js
@@ -0,0 +1,140 @@
+/*
+ * Copyright 2019 Brainbean Apps (https://brainbeanapps.com)
+ * License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
+ */
+odoo.define('web_widget_dropdown_dynamic.field_dynamic_dropdown', function (require) {
+ "use strict";
+
+ var core = require('web.core');
+ var AbstractField = require('web.AbstractField');
+ var field_registry = require('web.field_registry');
+
+ var _lt = core._lt;
+
+ var FieldDynamicDropdown = AbstractField.extend({
+ description: _lt('Dynamic Dropdown'),
+ template: 'FieldSelection',
+ specialData: '_fetchDynamicDropdownValues',
+ supportedFieldTypes: ['selection', 'char', 'integer'],
+ events: _.extend({}, AbstractField.prototype.events, {
+ 'change': '_onChange',
+ }),
+ /**
+ * @override
+ */
+ init: function () {
+ this._super.apply(this, arguments);
+ this._setValues();
+ },
+
+ //--------------------------------------------------------------------------
+ // Public
+ //--------------------------------------------------------------------------
+
+ /**
+ * @override
+ * @returns {jQuery}
+ */
+ getFocusableElement: function () {
+ return this.$el.is('select') ? this.$el : $();
+ },
+ /**
+ * @override
+ */
+ isSet: function () {
+ return this.value !== false;
+ },
+ /**
+ * Listen to modifiers updates to hide/show the falsy value in the dropdown
+ * according to the required modifier.
+ *
+ * @override
+ */
+ updateModifiersValue: function () {
+ this._super.apply(this, arguments);
+ if (!this.attrs.modifiersValue.invisible && this.mode !== 'readonly') {
+ this._setValues();
+ this._renderEdit();
+ }
+ },
+
+ //--------------------------------------------------------------------------
+ // Private
+ //--------------------------------------------------------------------------
+
+ /**
+ * @override
+ * @private
+ */
+ _formatValue: function (value) {
+ var options = _.extend({}, this.nodeOptions, { data: this.recordData }, this.formatOptions);
+ var formattedValue = _.find(this.values, function (option) {
+ return option[0] === value;
+ });
+ if (!formattedValue) {
+ return value;
+ }
+ formattedValue = formattedValue[1];
+ if (options && options.escape) {
+ formattedValue = _.escape(formattedValue);
+ }
+ return formattedValue;
+ },
+ /**
+ * @override
+ * @private
+ */
+ _renderEdit: function () {
+ this.$el.empty();
+ for (var i = 0 ; i < this.values.length ; i++) {
+ this.$el.append($('', {
+ value: JSON.stringify(this.values[i][0]),
+ text: this.values[i][1]
+ }));
+ }
+ this.$el.val(JSON.stringify(this.value));
+ },
+ /**
+ * @override
+ * @private
+ */
+ _renderReadonly: function () {
+ this.$el.empty().text(this._formatValue(this.value));
+ },
+ /**
+ * @override
+ */
+ _reset: function () {
+ this._super.apply(this, arguments);
+ this._setValues();
+ },
+ /**
+ * Sets the possible field values.
+ *
+ * @private
+ */
+ _setValues: function () {
+ this.values = _.reject(this.record.specialData[this.name], function (v) {
+ return v[0] === false && v[1] === '';
+ });
+ if (!this.attrs.modifiersValue || !this.attrs.modifiersValue.required) {
+ this.values = [[false, this.attrs.placeholder || '']].concat(this.values);
+ }
+ },
+
+ //--------------------------------------------------------------------------
+ // Handlers
+ //--------------------------------------------------------------------------
+
+ /**
+ * @private
+ */
+ _onChange: function () {
+ var value = JSON.parse(this.$el.val());
+ this._setValue(value.toString());
+ },
+ });
+ field_registry.add('dynamic_dropdown', FieldDynamicDropdown);
+
+ return FieldDynamicDropdown;
+});
diff --git a/web_widget_dropdown_dynamic/static/tests/web_widget_dropdown_dynamic_tests.js b/web_widget_dropdown_dynamic/static/tests/web_widget_dropdown_dynamic_tests.js
new file mode 100644
index 000000000..f25ac6581
--- /dev/null
+++ b/web_widget_dropdown_dynamic/static/tests/web_widget_dropdown_dynamic_tests.js
@@ -0,0 +1,177 @@
+odoo.define('web_widget_dropdown_dynamic.web_widget_dropdown_dynamic_tests', function (require) {
+ "use strict";
+
+ var FormView = require('web.FormView');
+ var testUtils = require('web.test_utils');
+
+ QUnit.module('web_widget_dropdown_dynamic', {}, function () {
+
+ QUnit.test('values are fetched w/o context (char)', async function (assert) {
+ assert.expect(2);
+
+ var form = await testUtils.createView({
+ View: FormView,
+ model: 'demo_entry',
+ data: {
+ demo_entry: {
+ fields: {
+ test_field: {string: 'Test Field', type: 'char'},
+ },
+ records: [{id: 1, test_field: ''}],
+ },
+ },
+ arch:
+ '',
+ mockRPC: function (route, args) {
+ if (args.method === '_get_test_field_values') {
+ return $.when([
+ ['value', 'Title'],
+ ]);
+ }
+ return this._super.apply(this, arguments);
+ },
+ });
+
+ assert.containsN(form, 'option', 2);
+ assert.containsOnce(form, 'option[value=\'"value"\']');
+
+ form.destroy();
+ });
+
+ QUnit.test('values are fetched w/o context (integer)', async function (assert) {
+ assert.expect(2);
+
+ var form = await testUtils.createView({
+ View: FormView,
+ model: 'demo_entry',
+ data: {
+ demo_entry: {
+ fields: {
+ test_field: {string: 'Test Field', type: 'integer'},
+ },
+ records: [{id: 1, test_field: 0}],
+ },
+ },
+ arch:
+ '',
+ mockRPC: function (route, args) {
+ if (args.method === '_get_test_field_values') {
+ return $.when([
+ [0, 'Title'],
+ ]);
+ }
+ return this._super.apply(this, arguments);
+ },
+ });
+
+ assert.containsN(form, 'option', 2);
+ assert.containsOnce(form, 'option[value=\'0\']');
+
+ form.destroy();
+ });
+
+ QUnit.test('values are fetched w/o context (selection)', async function (assert) {
+ assert.expect(2);
+
+ var form = await testUtils.createView({
+ View: FormView,
+ model: 'demo_entry',
+ data: {
+ demo_entry: {
+ fields: {
+ test_field: {string: 'Test Field', type: 'selection'},
+ },
+ records: [{id: 1, test_field: ''}],
+ },
+ },
+ arch:
+ '',
+ mockRPC: function (route, args) {
+ if (args.method === '_get_test_field_values') {
+ return $.when([
+ ['value', 'Title'],
+ ]);
+ }
+ return this._super.apply(this, arguments);
+ },
+ });
+
+ assert.containsN(form, 'option', 2);
+ assert.containsOnce(form, 'option[value=\'"value"\']');
+
+ form.destroy();
+ });
+
+ QUnit.test('values are fetched with changing context', async function (assert) {
+ assert.expect(6);
+
+ var form = await testUtils.createView({
+ View: FormView,
+ model: 'demo_entry',
+ data: {
+ demo_entry: {
+ fields: {
+ other_field: {string: 'Other Field', type: 'char'},
+ test_field: {string: 'Test Field', type: 'char'},
+ },
+ records: [{id: 1, other_field: '', test_field: ''}],
+ },
+ },
+ arch:
+ '',
+ mockRPC: function (route, args) {
+ if (args.method === '_get_test_field_values') {
+ if (args.kwargs.context.step === 'step-1') {
+ return $.when([
+ ['value', 'Title'],
+ ]);
+ } else if (args.kwargs.context.step === 'step-2') {
+ return $.when([
+ ['value', 'Title'],
+ ['value_2', 'Title 2'],
+ ]);
+ } else {
+ return $.when([]);
+ }
+ }
+ return this._super.apply(this, arguments);
+ },
+ });
+
+ await testUtils.fields.editAndTrigger(
+ form.$('.o_field_widget[name="other_field"]'),
+ 'step-1',
+ ['input']
+ );
+ assert.containsN(form, 'option', 2);
+ assert.containsOnce(form, 'option[value=\'"value"\']');
+
+ await testUtils.fields.editAndTrigger(
+ form.$('.o_field_widget[name="other_field"]'),
+ 'step-2',
+ ['input']
+ );
+ assert.containsN(form, 'option', 3);
+ assert.containsOnce(form, 'option[value=\'"value"\']');
+ assert.containsOnce(form, 'option[value=\'"value_2"\']');
+
+ await testUtils.fields.editAndTrigger(
+ form.$('.o_field_widget[name="other_field"]'),
+ 'step-other',
+ ['input']
+ );
+ assert.containsN(form, 'option', 1);
+
+ form.destroy();
+ });
+ });
+});
diff --git a/web_widget_dropdown_dynamic/templates/assets.xml b/web_widget_dropdown_dynamic/templates/assets.xml
new file mode 100644
index 000000000..70b958e96
--- /dev/null
+++ b/web_widget_dropdown_dynamic/templates/assets.xml
@@ -0,0 +1,19 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/web_widget_dropdown_dynamic_example/__init__.py b/web_widget_dropdown_dynamic_example/__init__.py
new file mode 100644
index 000000000..4b76c7b2d
--- /dev/null
+++ b/web_widget_dropdown_dynamic_example/__init__.py
@@ -0,0 +1,3 @@
+# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
+
+from . import models
diff --git a/web_widget_dropdown_dynamic_example/__manifest__.py b/web_widget_dropdown_dynamic_example/__manifest__.py
new file mode 100644
index 000000000..9418bcdf7
--- /dev/null
+++ b/web_widget_dropdown_dynamic_example/__manifest__.py
@@ -0,0 +1,20 @@
+# Copyright 2019 Brainbean Apps (https://brainbeanapps.com)
+# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
+{
+ 'name': 'Dynamic Dropdown Widget: Example',
+ 'summary': 'Demonstration of web_widget_dropdown_dynamic',
+ 'category': 'Web',
+ 'version': '12.0.1.0.0',
+ 'license': 'AGPL-3',
+ 'author':
+ 'Brainbean Apps OU, '
+ 'Odoo Community Association (OCA)',
+ 'website': 'https://github.com/OCA/web/',
+ 'depends': [
+ 'web_widget_dropdown_dynamic',
+ ],
+ 'data': [
+ 'views/web_widget_dropdown_dynamic_example.xml',
+ ],
+ 'installable': True,
+}
diff --git a/web_widget_dropdown_dynamic_example/models/__init__.py b/web_widget_dropdown_dynamic_example/models/__init__.py
new file mode 100644
index 000000000..8064e8466
--- /dev/null
+++ b/web_widget_dropdown_dynamic_example/models/__init__.py
@@ -0,0 +1,3 @@
+# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
+
+from . import web_widget_dropdown_dynamic_example
diff --git a/web_widget_dropdown_dynamic_example/models/web_widget_dropdown_dynamic_example.py b/web_widget_dropdown_dynamic_example/models/web_widget_dropdown_dynamic_example.py
new file mode 100644
index 000000000..6684d4a85
--- /dev/null
+++ b/web_widget_dropdown_dynamic_example/models/web_widget_dropdown_dynamic_example.py
@@ -0,0 +1,87 @@
+# Copyright 2019 Brainbean Apps (https://brainbeanapps.com)
+# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
+
+from odoo import api, fields, models
+
+
+class WebWidgetDropdownDynamicExample(models.TransientModel):
+ _name = 'web.widget.dropdown.dynamic.example'
+ _description = 'Web Widget Dropdown Dynamic Example'
+
+ name = fields.Char(
+ default='Web Widget Dropdown Dynamic Example',
+ required=True,
+ )
+
+ char_field_options = fields.Text(
+ string='Char field options',
+ default=(
+ 'Option A\n'
+ 'Option B\n'
+ 'Option C\n'
+ ),
+ )
+ char_field = fields.Char(
+ string='Char field',
+ )
+
+ int_field_min = fields.Integer(
+ string='Int field (min)',
+ default=0,
+ )
+ int_field_max = fields.Integer(
+ string='Int field (max)',
+ default=9,
+ )
+ int_field = fields.Integer(
+ string='Int field',
+ )
+
+ selection_field_options = fields.Text(
+ string='Selection field options',
+ default=(
+ 'Option A\n'
+ 'Option B\n'
+ 'Option C\n'
+ 'Option D\n'
+ ),
+ )
+ selection_field = fields.Char(
+ string='Selection field',
+ selection=[
+ ('Option A', 'Option A'),
+ ('Option B', 'Option B'),
+ ('Option C', 'Option C'),
+ ]
+ )
+
+ @api.model
+ def values_char_field(self):
+ options = self.env.context.get('options').strip().split('\n')
+ return list(map(
+ lambda option: (option, option),
+ filter(
+ lambda option: bool(option),
+ options
+ )
+ ))
+
+ @api.model
+ def values_int_field(self):
+ min_value = int(self.env.context.get('min'))
+ max_value = int(self.env.context.get('max'))
+ options = []
+ for value in range(min_value, max_value + 1):
+ options.append((value, str(value)))
+ return options
+
+ @api.model
+ def values_selection_field(self):
+ options = self.env.context.get('options').strip().split('\n')
+ return list(map(
+ lambda option: (option, option),
+ filter(
+ lambda option: bool(option),
+ options
+ )
+ ))
diff --git a/web_widget_dropdown_dynamic_example/views/web_widget_dropdown_dynamic_example.xml b/web_widget_dropdown_dynamic_example/views/web_widget_dropdown_dynamic_example.xml
new file mode 100644
index 000000000..dcd506618
--- /dev/null
+++ b/web_widget_dropdown_dynamic_example/views/web_widget_dropdown_dynamic_example.xml
@@ -0,0 +1,58 @@
+
+
+
+
+
+ web.widget.dropdown.dynamic.example.form
+ web.widget.dropdown.dynamic.example
+
+
+
+
+
+
+ web_widget_dropdown_dynamic Demo
+ web.widget.dropdown.dynamic.example
+ form
+ form
+
+
+
+
+
From 8ed2e78d6b06c0e531bbe9f440456dbd73e5af1a Mon Sep 17 00:00:00 2001
From: oca-travis
Date: Tue, 12 Nov 2019 09:43:29 +0000
Subject: [PATCH 2/7] [UPD] Update web_widget_dropdown_dynamic.pot
---
.../i18n/web_widget_dropdown_dynamic.pot | 22 +++++++++++++++++++
1 file changed, 22 insertions(+)
create mode 100644 web_widget_dropdown_dynamic/i18n/web_widget_dropdown_dynamic.pot
diff --git a/web_widget_dropdown_dynamic/i18n/web_widget_dropdown_dynamic.pot b/web_widget_dropdown_dynamic/i18n/web_widget_dropdown_dynamic.pot
new file mode 100644
index 000000000..673c92c99
--- /dev/null
+++ b/web_widget_dropdown_dynamic/i18n/web_widget_dropdown_dynamic.pot
@@ -0,0 +1,22 @@
+# Translation of Odoo Server.
+# This file contains the translation of the following modules:
+# * web_widget_dropdown_dynamic
+#
+msgid ""
+msgstr ""
+"Project-Id-Version: Odoo Server 12.0\n"
+"Report-Msgid-Bugs-To: \n"
+"Last-Translator: <>\n"
+"Language-Team: \n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=UTF-8\n"
+"Content-Transfer-Encoding: \n"
+"Plural-Forms: \n"
+
+#. module: web_widget_dropdown_dynamic
+#. openerp-web
+#: code:addons/web_widget_dropdown_dynamic/static/src/js/field_dynamic_dropdown.js:15
+#, python-format
+msgid "Dynamic Dropdown"
+msgstr ""
+
From e543a8eff0aaf159c0dbcee234d3ab887511beb5 Mon Sep 17 00:00:00 2001
From: oca-travis
Date: Tue, 12 Nov 2019 09:43:30 +0000
Subject: [PATCH 3/7] [UPD] Update web_widget_dropdown_dynamic_example.pot
---
.../web_widget_dropdown_dynamic_example.pot | 119 ++++++++++++++++++
1 file changed, 119 insertions(+)
create mode 100644 web_widget_dropdown_dynamic_example/i18n/web_widget_dropdown_dynamic_example.pot
diff --git a/web_widget_dropdown_dynamic_example/i18n/web_widget_dropdown_dynamic_example.pot b/web_widget_dropdown_dynamic_example/i18n/web_widget_dropdown_dynamic_example.pot
new file mode 100644
index 000000000..5256aed10
--- /dev/null
+++ b/web_widget_dropdown_dynamic_example/i18n/web_widget_dropdown_dynamic_example.pot
@@ -0,0 +1,119 @@
+# Translation of Odoo Server.
+# This file contains the translation of the following modules:
+# * web_widget_dropdown_dynamic_example
+#
+msgid ""
+msgstr ""
+"Project-Id-Version: Odoo Server 12.0\n"
+"Report-Msgid-Bugs-To: \n"
+"Last-Translator: <>\n"
+"Language-Team: \n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=UTF-8\n"
+"Content-Transfer-Encoding: \n"
+"Plural-Forms: \n"
+
+#. module: web_widget_dropdown_dynamic_example
+#: model:ir.model.fields,field_description:web_widget_dropdown_dynamic_example.field_web_widget_dropdown_dynamic_example__char_field
+#: model_terms:ir.ui.view,arch_db:web_widget_dropdown_dynamic_example.web_widget_dropdown_dynamic_example_form
+msgid "Char field"
+msgstr ""
+
+#. module: web_widget_dropdown_dynamic_example
+#: model:ir.model.fields,field_description:web_widget_dropdown_dynamic_example.field_web_widget_dropdown_dynamic_example__char_field_options
+msgid "Char field options"
+msgstr ""
+
+#. module: web_widget_dropdown_dynamic_example
+#: model:ir.model.fields,field_description:web_widget_dropdown_dynamic_example.field_web_widget_dropdown_dynamic_example__create_uid
+msgid "Created by"
+msgstr ""
+
+#. module: web_widget_dropdown_dynamic_example
+#: model:ir.model.fields,field_description:web_widget_dropdown_dynamic_example.field_web_widget_dropdown_dynamic_example__create_date
+msgid "Created on"
+msgstr ""
+
+#. module: web_widget_dropdown_dynamic_example
+#: model:ir.model.fields,field_description:web_widget_dropdown_dynamic_example.field_web_widget_dropdown_dynamic_example__display_name
+msgid "Display Name"
+msgstr ""
+
+#. module: web_widget_dropdown_dynamic_example
+#: model:ir.model.fields,field_description:web_widget_dropdown_dynamic_example.field_web_widget_dropdown_dynamic_example__id
+msgid "ID"
+msgstr ""
+
+#. module: web_widget_dropdown_dynamic_example
+#: model:ir.model.fields,field_description:web_widget_dropdown_dynamic_example.field_web_widget_dropdown_dynamic_example__int_field
+#: model_terms:ir.ui.view,arch_db:web_widget_dropdown_dynamic_example.web_widget_dropdown_dynamic_example_form
+msgid "Int field"
+msgstr ""
+
+#. module: web_widget_dropdown_dynamic_example
+#: model:ir.model.fields,field_description:web_widget_dropdown_dynamic_example.field_web_widget_dropdown_dynamic_example__int_field_max
+msgid "Int field (max)"
+msgstr ""
+
+#. module: web_widget_dropdown_dynamic_example
+#: model:ir.model.fields,field_description:web_widget_dropdown_dynamic_example.field_web_widget_dropdown_dynamic_example__int_field_min
+msgid "Int field (min)"
+msgstr ""
+
+#. module: web_widget_dropdown_dynamic_example
+#: model:ir.model.fields,field_description:web_widget_dropdown_dynamic_example.field_web_widget_dropdown_dynamic_example____last_update
+msgid "Last Modified on"
+msgstr ""
+
+#. module: web_widget_dropdown_dynamic_example
+#: model:ir.model.fields,field_description:web_widget_dropdown_dynamic_example.field_web_widget_dropdown_dynamic_example__write_uid
+msgid "Last Updated by"
+msgstr ""
+
+#. module: web_widget_dropdown_dynamic_example
+#: model:ir.model.fields,field_description:web_widget_dropdown_dynamic_example.field_web_widget_dropdown_dynamic_example__write_date
+msgid "Last Updated on"
+msgstr ""
+
+#. module: web_widget_dropdown_dynamic_example
+#: model:ir.model.fields,field_description:web_widget_dropdown_dynamic_example.field_web_widget_dropdown_dynamic_example__name
+msgid "Name"
+msgstr ""
+
+#. module: web_widget_dropdown_dynamic_example
+#: selection:web.widget.dropdown.dynamic.example,selection_field:0
+msgid "Option A"
+msgstr ""
+
+#. module: web_widget_dropdown_dynamic_example
+#: selection:web.widget.dropdown.dynamic.example,selection_field:0
+msgid "Option B"
+msgstr ""
+
+#. module: web_widget_dropdown_dynamic_example
+#: selection:web.widget.dropdown.dynamic.example,selection_field:0
+msgid "Option C"
+msgstr ""
+
+#. module: web_widget_dropdown_dynamic_example
+#: model:ir.model.fields,field_description:web_widget_dropdown_dynamic_example.field_web_widget_dropdown_dynamic_example__selection_field
+#: model_terms:ir.ui.view,arch_db:web_widget_dropdown_dynamic_example.web_widget_dropdown_dynamic_example_form
+msgid "Selection field"
+msgstr ""
+
+#. module: web_widget_dropdown_dynamic_example
+#: model:ir.model.fields,field_description:web_widget_dropdown_dynamic_example.field_web_widget_dropdown_dynamic_example__selection_field_options
+msgid "Selection field options"
+msgstr ""
+
+#. module: web_widget_dropdown_dynamic_example
+#: model:ir.model,name:web_widget_dropdown_dynamic_example.model_web_widget_dropdown_dynamic_example
+msgid "Web Widget Dropdown Dynamic Example"
+msgstr ""
+
+#. module: web_widget_dropdown_dynamic_example
+#: model:ir.actions.act_window,name:web_widget_dropdown_dynamic_example.action_web_widget_dropdown_dynamic_example
+#: model:ir.ui.menu,name:web_widget_dropdown_dynamic_example.web_widget_dropdown_dynamic_example_menu
+msgid "web_widget_dropdown_dynamic Demo"
+msgstr ""
+
From 29a71d9a9a34a4fa5a547548fdc77aab1bf2a84c Mon Sep 17 00:00:00 2001
From: OCA-git-bot
Date: Tue, 12 Nov 2019 09:57:47 +0000
Subject: [PATCH 4/7] [UPD] README.rst
---
web_widget_dropdown_dynamic/README.rst | 114 +++++
.../static/description/index.html | 465 ++++++++++++++++++
2 files changed, 579 insertions(+)
create mode 100644 web_widget_dropdown_dynamic/README.rst
create mode 100644 web_widget_dropdown_dynamic/static/description/index.html
diff --git a/web_widget_dropdown_dynamic/README.rst b/web_widget_dropdown_dynamic/README.rst
new file mode 100644
index 000000000..21d266392
--- /dev/null
+++ b/web_widget_dropdown_dynamic/README.rst
@@ -0,0 +1,114 @@
+=======================
+Dynamic Dropdown Widget
+=======================
+
+.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+ !! This file is generated by oca-gen-addon-readme !!
+ !! changes will be overwritten. !!
+ !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+
+.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
+ :target: https://odoo-community.org/page/development-status
+ :alt: Beta
+.. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png
+ :target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
+ :alt: License: AGPL-3
+.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fweb-lightgray.png?logo=github
+ :target: https://github.com/OCA/web/tree/12.0/web_widget_dropdown_dynamic
+ :alt: OCA/web
+.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
+ :target: https://translation.odoo-community.org/projects/web-12-0/web-12-0-web_widget_dropdown_dynamic
+ :alt: Translate me on Weblate
+.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png
+ :target: https://runbot.odoo-community.org/runbot/162/12.0
+ :alt: Try me on Runbot
+
+|badge1| |badge2| |badge3| |badge4| |badge5|
+
+Dynamic dropdown widget that supports resolving options from backend of:
+
+ * ``fields.Char``
+ * ``fields.Integer``
+ * ``fields.Selection``
+
+**NOTE:** This widget is not intended to *extend* ``fields.Selection``, but to
+filter selection values. For fully-dynamic set of options, use ``fields.Char``
+instead.
+
+**Table of contents**
+
+.. contents::
+ :local:
+
+Usage
+=====
+
+.. code-block:: python
+
+ @api.model
+ def method_name(self):
+ values = [
+ ('value_a', 'Title A'),
+ ]
+ if self.env.context.get('depending_on') == True:
+ values += [
+ ('value_b', 'Title B'),
+ ]
+ return values
+
+.. code-block:: xml
+
+
+
+
+Known issues / Roadmap
+======================
+
+ * In v13, ``$.when`` is going to become `Promise.resolve`
+
+Bug Tracker
+===========
+
+Bugs are tracked on `GitHub Issues `_.
+In case of trouble, please check there if your issue has already been reported.
+If you spotted it first, help us smashing it by providing a detailed and welcomed
+`feedback `_.
+
+Do not contact contributors directly about support or help with technical issues.
+
+Credits
+=======
+
+Authors
+~~~~~~~
+
+* Brainbean Apps OU
+
+Contributors
+~~~~~~~~~~~~
+
+* Alexey Pelykh
+
+Maintainers
+~~~~~~~~~~~
+
+This module is maintained by the OCA.
+
+.. image:: https://odoo-community.org/logo.png
+ :alt: Odoo Community Association
+ :target: https://odoo-community.org
+
+OCA, or the Odoo Community Association, is a nonprofit organization whose
+mission is to support the collaborative development of Odoo features and
+promote its widespread use.
+
+This module is part of the `OCA/web `_ project on GitHub.
+
+You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
diff --git a/web_widget_dropdown_dynamic/static/description/index.html b/web_widget_dropdown_dynamic/static/description/index.html
new file mode 100644
index 000000000..82089dc28
--- /dev/null
+++ b/web_widget_dropdown_dynamic/static/description/index.html
@@ -0,0 +1,465 @@
+
+
+
+
+
+
+Dynamic Dropdown Widget
+
+
+
+
+
Dynamic Dropdown Widget
+
+
+
+
Dynamic dropdown widget that supports resolving options from backend of:
+
+
+
fields.Char
+
fields.Integer
+
fields.Selection
+
+
+
NOTE: This widget is not intended to extendfields.Selection, but to
+filter selection values. For fully-dynamic set of options, use fields.Char
+instead.
Bugs are tracked on GitHub Issues.
+In case of trouble, please check there if your issue has already been reported.
+If you spotted it first, help us smashing it by providing a detailed and welcomed
+feedback.
+
Do not contact contributors directly about support or help with technical issues.
OCA, or the Odoo Community Association, is a nonprofit organization whose
+mission is to support the collaborative development of Odoo features and
+promote its widespread use.
+
This module is part of the OCA/web project on GitHub.
-@api.model
+@api.modeldefmethod_name(self):values=[('value_a','Title A'),]
- ifself.env.context.get('depending_on')==True:
+ ifself.env.context.get('depending_on')==True:values+=[('value_b','Title B'),]
From 2c882ab01d9923a76418e0b5cb9f2f494166e40d Mon Sep 17 00:00:00 2001
From: Alexey Pelykh
Date: Sun, 12 Apr 2020 08:32:28 +0200
Subject: [PATCH 7/7] [MIG] web_widget_dropdown_dynamic: Backport to 11.0
---
web_widget_dropdown_dynamic/README.rst | 10 +++++-----
web_widget_dropdown_dynamic/__manifest__.py | 4 ++--
.../static/description/index.html | 6 +++---
web_widget_dropdown_dynamic_example/__manifest__.py | 4 ++--
4 files changed, 12 insertions(+), 12 deletions(-)
diff --git a/web_widget_dropdown_dynamic/README.rst b/web_widget_dropdown_dynamic/README.rst
index 21d266392..cd112a977 100644
--- a/web_widget_dropdown_dynamic/README.rst
+++ b/web_widget_dropdown_dynamic/README.rst
@@ -14,16 +14,16 @@ Dynamic Dropdown Widget
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
:alt: License: AGPL-3
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fweb-lightgray.png?logo=github
- :target: https://github.com/OCA/web/tree/12.0/web_widget_dropdown_dynamic
+ :target: https://github.com/OCA/web/tree/11.0/web_widget_dropdown_dynamic
:alt: OCA/web
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
:target: https://translation.odoo-community.org/projects/web-12-0/web-12-0-web_widget_dropdown_dynamic
:alt: Translate me on Weblate
.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png
- :target: https://runbot.odoo-community.org/runbot/162/12.0
+ :target: https://runbot.odoo-community.org/runbot/162/11.0
:alt: Try me on Runbot
-|badge1| |badge2| |badge3| |badge4| |badge5|
+|badge1| |badge2| |badge3| |badge4| |badge5|
Dynamic dropdown widget that supports resolving options from backend of:
@@ -79,7 +79,7 @@ Bug Tracker
Bugs are tracked on `GitHub Issues `_.
In case of trouble, please check there if your issue has already been reported.
If you spotted it first, help us smashing it by providing a detailed and welcomed
-`feedback `_.
+`feedback `_.
Do not contact contributors directly about support or help with technical issues.
@@ -109,6 +109,6 @@ OCA, or the Odoo Community Association, is a nonprofit organization whose
mission is to support the collaborative development of Odoo features and
promote its widespread use.
-This module is part of the `OCA/web `_ project on GitHub.
+This module is part of the `OCA/web `_ project on GitHub.
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
diff --git a/web_widget_dropdown_dynamic/__manifest__.py b/web_widget_dropdown_dynamic/__manifest__.py
index 8ede2ec51..378ded886 100644
--- a/web_widget_dropdown_dynamic/__manifest__.py
+++ b/web_widget_dropdown_dynamic/__manifest__.py
@@ -1,10 +1,10 @@
-# Copyright 2019 Brainbean Apps (https://brainbeanapps.com)
+# Copyright 2019-2020 Brainbean Apps (https://brainbeanapps.com)
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
{
'name': 'Dynamic Dropdown Widget',
'summary': 'This module adds support for dynamic dropdown widget',
'category': 'Web',
- 'version': '12.0.1.0.0',
+ 'version': '11.0.1.0.0',
'license': 'AGPL-3',
'author':
'Brainbean Apps OU, '
diff --git a/web_widget_dropdown_dynamic/static/description/index.html b/web_widget_dropdown_dynamic/static/description/index.html
index d17e254a2..f085845ff 100644
--- a/web_widget_dropdown_dynamic/static/description/index.html
+++ b/web_widget_dropdown_dynamic/static/description/index.html
@@ -367,7 +367,7 @@ ul.auto-toc {
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
-
+
Dynamic dropdown widget that supports resolving options from backend of:
@@ -432,7 +432,7 @@ instead.
Bugs are tracked on GitHub Issues.
In case of trouble, please check there if your issue has already been reported.
If you spotted it first, help us smashing it by providing a detailed and welcomed
-feedback.
Do not contact contributors directly about support or help with technical issues.
@@ -456,7 +456,7 @@ If you spotted it first, help us smashing it by providing a detailed and welcome
OCA, or the Odoo Community Association, is a nonprofit organization whose
mission is to support the collaborative development of Odoo features and
promote its widespread use.
-
This module is part of the OCA/web project on GitHub.
+
This module is part of the OCA/web project on GitHub.