summaryrefslogtreecommitdiff
path: root/addons/web/static/src
diff options
context:
space:
mode:
authorNans Lefebvre <len@odoo.com>2019-01-30 13:12:22 +0000
committerNans Lefebvre <len@odoo.com>2019-01-31 07:35:46 +0000
commitb7983443b662900123a9e75fd932bdd0c3a38c07 (patch)
tree53b6020dea3a07047acbc5bbf7e087ada9eb9ecd /addons/web/static/src
parent6ce2d6efb5b53451f369d544a31c36a024e0faf5 (diff)
[FIX] web: make value_from of Datefield work without calling complete before
Commit 9af941428880af8e1810dfd9feef494d7a745e98 made it so that the value_from function depends on a variable defined after the function complete has been called, without any guarantee that this function would be called after. Apparently this is the right OOP thing to do. opw 1930523 closes odoo/odoo#30712
Diffstat (limited to 'addons/web/static/src')
-rw-r--r--addons/web/static/src/js/chrome/search_inputs.js6
1 files changed, 5 insertions, 1 deletions
diff --git a/addons/web/static/src/js/chrome/search_inputs.js b/addons/web/static/src/js/chrome/search_inputs.js
index 59126ecb37c..579f587b0b5 100644
--- a/addons/web/static/src/js/chrome/search_inputs.js
+++ b/addons/web/static/src/js/chrome/search_inputs.js
@@ -342,7 +342,11 @@ var BooleanField = SelectionField.extend(/** @lends instance.web.search.BooleanF
var DateField = Field.extend(/** @lends instance.web.search.DateField# */{
value_from: function (facetValue) {
var serverFormat = (this.attrs && this.attrs.type === 'datetime') ? 'YYYY-MM-DD HH:mm:ss' : 'YYYY-MM-DD';
- return facetValue.get('valueAsMoment').clone().format(serverFormat);
+ if (facetValue.get('valueAsMoment')) {
+ return facetValue.get('valueAsMoment').clone().format(serverFormat);
+ } else {
+ return moment(facetValue.get('value')).format(serverFormat);
+ }
},
complete: function (needle) {
// Make sure the needle has a correct format before the creation of the moment object. See