Cast Date and Time field value to the correct type when checking for modification

issue10655
review352481002
(grafted from b03d7d7e0225a0a582eae5ddf0f79324760f58c6)

--HG--
branch : 6.0
This commit is contained in:
Adrià Tarroja Caubet committed 2021-09-02 23:30:57 +02:00
1 parent 9202300f26
commit bccc6c4a1d
2 files changed
+28 -7

No files matched your search

+10 -5
View File
@@ -262,15 +262,20 @@ var Sao = {};
}
datetime.isDateTime = true;
datetime.local();
datetime.todate = function() {
return Sao.Date(this.year(), this.month(), this.date());
};
datetime.totime = function() {
return Sao.Time(
this.hour(), this.minute(), this.second(), this.millisecond());
};
return datetime;
};
Sao.DateTime.combine = function(date, time) {
var datetime = date.clone();
datetime.set({hour: time.hour(), minute: time.minute(),
second: time.second(), millisecond: time.millisecond()});
datetime.isDateTime = true;
return datetime;
return Sao.DateTime(
date.year(), date.month(), date.date(),
time.hour(), time.minute(), time.second(), time.millisecond());
};
Sao.DateTime.min = moment(new Date(-100000000 * 86400000)).local();
+18 -2
View File
@@ -1692,7 +1692,8 @@ function eval_pyson(value){
},
get modified() {
if (this.record && this.field) {
var field_value = this.field.get_client(this.record);
var field_value = this.cast(
this.field.get_client(this.record));
return (JSON.stringify(field_value) !=
JSON.stringify(this.get_value()));
}
@@ -1711,7 +1712,13 @@ function eval_pyson(value){
this.icon.show();
}
}
}
},
cast: function(value){
if (value && value.isDateTime) {
value = value.todate();
}
return value;
},
});
Sao.View.Form.DateTime = Sao.class_(Sao.View.Form.Date, {
@@ -1730,6 +1737,9 @@ function eval_pyson(value){
return this._default_format;
}
},
cast: function(value){
return value;
},
});
Sao.View.Form.Time = Sao.class_(Sao.View.Form.Date, {
@@ -1754,6 +1764,12 @@ function eval_pyson(value){
return this._default_format;
}
},
cast: function(value){
if (value && value.isDateTime) {
value = value.totime();
}
return value;
},
});
Sao.View.Form.TimeDelta = Sao.class_(Sao.View.Form.Widget, {