[FIX] web: save date(time) field value on key enter in editable list
authorDenis Ledoux <dle@odoo.com>
Tue, 17 Jun 2014 10:56:13 +0000 (12:56 +0200)
committerDenis Ledoux <dle@odoo.com>
Tue, 17 Jun 2014 10:56:13 +0000 (12:56 +0200)
In editable list, on keypress enter, the _next method is called, saving the current line and starting the edition of the next one
The _next is triggered before the date(time) field change event, and, therefore, the saved value of the date(time) field is the old one

addons/web/static/src/js/view_form.js

index e9f195b..fec7ce1 100644 (file)
@@ -2422,6 +2422,7 @@ instance.web.DateTimeWidget = instance.web.Widget.extend({
     type_of_date: "datetime",
     events: {
         'change .oe_datepicker_master': 'change_datetime',
+        'keypress .oe_datepicker_master': 'change_datetime',
     },
     init: function(parent) {
         this._super(parent);
@@ -2540,8 +2541,8 @@ instance.web.DateTimeWidget = instance.web.Widget.extend({
     format_client: function(v) {
         return instance.web.format_value(v, {"widget": this.type_of_date});
     },
-    change_datetime: function() {
-        if (this.is_valid_()) {
+    change_datetime: function(e) {
+        if ((e.type !== "keypress" || e.which === 13) && this.is_valid_()) {
             this.set_value_from_ui_();
             this.trigger("datetime_changed");
         }