changeset 260935853afe in sao:5.0
details: https://hg.tryton.org/sao?cmd=changeset;node=260935853afe
description:
Use locale context to format date in domain parser
issue8999
review278401002
(grafted from 61b6bde722d965e11bf56628bed4b70a4fd2fca3)
diffstat:
src/common.js | 28 +++++++++++++++++-----------
1 files changed, 17 insertions(+), 11 deletions(-)
diffs (96 lines):
diff -r 00e13027200f -r 260935853afe src/common.js
--- a/src/common.js Sun Feb 02 17:07:55 2020 +0100
+++ b/src/common.js Tue Feb 04 18:28:09 2020 +0100
@@ -1695,8 +1695,8 @@
'time'].indexOf(field.type)) {
if ((typeof value == 'string') &&
value.contains('..')) {
var values = value.split('..', 2);
- var lvalue = this.convert_value(field, values[0]);
- var rvalue = this.convert_value(field, values[1]);
+ var lvalue = this.convert_value(field, values[0],
this.context);
+ var rvalue = this.convert_value(field, values[1],
this.context);
result.push([
this._clausify([field_name, '>=', lvalue]),
this._clausify([field_name, '<=', rvalue])
@@ -1706,14 +1706,14 @@
}
if (value instanceof Array) {
value = value.map(function(v) {
- return this.convert_value(field, v);
+ return this.convert_value(field, v, this.context);
}.bind(this));
if (~['many2one', 'one2many', 'many2many', 'one2one',
'many2many', 'one2one'].indexOf(field.type)) {
field_name += '.rec_name';
}
} else {
- value = this.convert_value(field, value);
+ value = this.convert_value(field, value, this.context);
}
if (operator.contains('like')) {
value = this.likify(value);
@@ -1797,7 +1797,10 @@
}
return [target, value];
},
- convert_value: function(field, value) {
+ convert_value: function(field, value, context) {
+ if (!context) {
+ context = {};
+ }
var convert_selection = function() {
if (typeof value == 'string') {
for (var i = 0; i < field.selection.length; i++) {
@@ -1860,14 +1863,14 @@
'reference': convert_selection,
'datetime': function() {
var result = Sao.common.parse_datetime(
- Sao.common.date_format(),
+ Sao.common.date_format(context.date_format),
this.time_format(field),
value);
return result;
}.bind(this),
'date': function() {
return Sao.common.parse_date(
- Sao.common.date_format(),
+ Sao.common.date_format(context.date_format),
value);
},
'time': function() {
@@ -1900,10 +1903,13 @@
return value;
}
},
- format_value: function(field, value, target) {
+ format_value: function(field, value, target, context) {
if (target === undefined) {
target = null;
}
+ if (!context) {
+ context = {};
+ }
var format_float = function() {
if (!value && value !== 0 && value !== new Sao.Decimal(0)) {
return '';
@@ -1969,17 +1975,17 @@
value.minute() ||
value.second())) {
return Sao.common.format_date(
- Sao.common.date_format(),
+ Sao.common.date_format(context.date_format),
value);
}
return Sao.common.format_datetime(
- Sao.common.date_format(),
+ Sao.common.date_format(context.date_format),
this.time_format(field),
value);
}.bind(this),
'date': function() {
return Sao.common.format_date(
- Sao.common.date_format(),
+ Sao.common.date_format(context.date_format),
value);
},
'time': function() {