[ADD] web_widget_dropdown_dynamic

[UPD] Update web_widget_dropdown_dynamic.pot

[UPD] Update web_widget_dropdown_dynamic_example.pot

[UPD] README.rst

[ADD] icon.png

[UPD] README.rst
This commit is contained in:
Alexey Pelykh
2019-09-11 14:04:03 +02:00
parent d83aa81376
commit 2b6ba77540
21 changed files with 1330 additions and 0 deletions

View File

@@ -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<any>}
* 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,
});
},
});
});