[FIX] web: Remove offset only for datetime field, not date

Since https://github.com/odoo/odoo/pull/87584

with `date` field, pressing enter will removes 1 day to the value.
To fix it we have to ignore the offset suppression used for `datetime`

opw-2818927

closes odoo/odoo#90115

X-original-commit: 46e6475708c7ba8289345c4f7c125f60fc77d08c
Signed-off-by: Achraf <abz@odoo.com>
This commit is contained in:
Achraf (abz)
2022-04-29 13:13:30 +02:00
parent abb024a3cc
commit 2d651e665c
2 changed files with 8 additions and 1 deletions
@@ -1001,7 +1001,9 @@ var FieldDate = InputField.extend({
let value = this.$input.val();
try {
value = this._parseValue(value);
value.add(-this.getSession().getTZOffset(value), "minutes");
if (this.field.type === "datetime") {
value.add(-this.getSession().getTZOffset(value), "minutes");
}
} catch (_err) {}
await this._setValue(value);
this._render();
@@ -4675,6 +4675,11 @@ QUnit.module('basic_fields', {
viewOptions: {
mode: 'edit',
},
session: {
getTZOffset: function () {
return 120;
},
},
});
const year = (new Date()).getFullYear();