summaryrefslogtreecommitdiff
path: root/addons/web/static/src/js/fields
diff options
context:
space:
mode:
authorGéry Debongnie <ged@odoo.com>2017-05-08 10:55:46 +0200
committerGéry Debongnie <ged@odoo.com>2017-05-08 13:56:18 +0200
commitc8d77f93e5a857acd22025f4a8d4d42d674479d1 (patch)
tree1591b578e28a64b929cf3aa3c9da7eea1cc93f49 /addons/web/static/src/js/fields
parentaeae2fb64f16bbcf910d37b194f11e189febcae9 (diff)
[FIX] web: display empty input fields properly
Before this commit, it was not possible to see the difference between an unset float field (with a 'false' value) and a set field (for ex, with value 0) This was due to the fact that the formatFloat/formatMonetary functions format false values as the number 0, unlike many other formatting functions.
Diffstat (limited to 'addons/web/static/src/js/fields')
-rw-r--r--addons/web/static/src/js/fields/basic_fields.js3
-rw-r--r--addons/web/static/src/js/fields/field_utils.js14
2 files changed, 10 insertions, 7 deletions
diff --git a/addons/web/static/src/js/fields/basic_fields.js b/addons/web/static/src/js/fields/basic_fields.js
index 9df9a49fac2..3e9ea89be31 100644
--- a/addons/web/static/src/js/fields/basic_fields.js
+++ b/addons/web/static/src/js/fields/basic_fields.js
@@ -93,9 +93,6 @@ var DebouncedField = AbstractField.extend({
// _debouncedStarted is used to detect that the user interacted at least
// once with the widget, so that we can prevent it from triggering a
// field_changed in commitChanges if the user didn't change anything
- // (this is required as sometimes it is hard to detect that an unset
- // value is still unset, e.g. if a numerical field contains the value 0,
- // is it because it is still unset or because the user set it to 0?
this._debouncedStarted = false;
if (this.mode === 'edit') {
if (this.DEBOUNCE) {
diff --git a/addons/web/static/src/js/fields/field_utils.js b/addons/web/static/src/js/fields/field_utils.js
index 9a683954e7e..ed3014d9bb6 100644
--- a/addons/web/static/src/js/fields/field_utils.js
+++ b/addons/web/static/src/js/fields/field_utils.js
@@ -71,7 +71,7 @@ function formatChar(value) {
* @returns {string}
*/
function formatDate(value, field, options) {
- if (!value) {
+ if (value === false) {
return "";
}
if (!options || !('timezone' in options) || options.timezone) {
@@ -96,7 +96,7 @@ function formatDate(value, field, options) {
* @returns {string}
*/
function formatDateTime(value, field, options) {
- if (!value) {
+ if (value === false) {
return "";
}
if (!options || !('timezone' in options) || options.timezone) {
@@ -113,7 +113,7 @@ function formatDateTime(value, field, options) {
* Returns a string representing a float. The result takes into account the
* user settings (to display the correct decimal separator).
*
- * @param {float} value the value that should be formatted
+ * @param {float|false} value the value that should be formatted
* @param {Object} [field] a description of the field (returned by fields_get
* for example). It may contain a description of the number of digits that
* should be used.
@@ -124,6 +124,9 @@ function formatDateTime(value, field, options) {
* @returns {string}
*/
function formatFloat(value, field, options) {
+ if (value === false) {
+ return "";
+ }
var l10n = core._t.database.parameters;
var precision;
if (options && options.digits) {
@@ -213,7 +216,7 @@ function formatX2Many(value) {
* Returns a string representing a monetary value. The result takes into account
* the user settings (to display the correct decimal separator, currency, ...).
*
- * @param {float} value the value that should be formatted
+ * @param {float|false} value the value that should be formatted
* @param {Object} [field]
* a description of the field (returned by fields_get for example). It
* may contain a description of the number of digits that should be used.
@@ -238,6 +241,9 @@ function formatX2Many(value) {
* @returns {string}
*/
function formatMonetary(value, field, options) {
+ if (value === false) {
+ return "";
+ }
options = options || {};
var currency = options.currency;