Odoo Help

6
6
tolstoj
On 2/18/13, 11:45 AM

I will answer my question myself. If your customer want to use ENTER button as a TAB button in product list of sale order, you must edit view_list_editable.js:483

keyup_ENTER: function () {
    return this._next();
},

and put where something like that:

keyup_ENTER: function (e) {
        var source_field = $(e.target).closest('[data-fieldname]').attr('data-fieldname');
        var fields_order = this.editor.form.fields_order;
        var field_index  = _(fields_order).indexOf(source_field);            
        var fields       = this.editor.form.fields;
        var field;
        do {
            if (++field_index >= fields_order.length) {
                e.preventDefault();
                return this._next();
            }
            field = fields[fields_order[field_index]];
        } while (!field.$el.is(':visible'));
        field.focus();
        return $.when();
    },

it's mainly from keydown_RIGHT func. because it has same logic. It's work's only for text fields. For text-area field you must handle stopPropagation() for ENTER key event in text-area fields in view_form.js

this code is not working......please help..

Rishabh
on 5/28/13, 3:44 AM
0
Sody
On 7/31/14, 10:51 AM

HI,

I would like to block ENTER only on open page, in grid where can user create new position.

How to do this ?

 

0
Benjamin Ujvari-Cseh
On 2/25/14, 6:11 AM

If you don't want to use the "Enter" key, you can use the "+" key from the numpad which is just above.

This is interesting because you keep the default behavior of "Enter" key as long as you don't have "+" character in your field. If you have it, you can use the other "+" key, which doesn't come with the same keycode.

The only problem is when you type with this key: it adds the character '+' on the field. But you can disable this with this code:

    keydown_NUMPAD_ADD: function (e) {
        e.preventDefault();
        return $.when();
    }

In order to have the same behavior of "Tab" key, just use @tolstoj code:

    keyup_NUMPAD_ADD: function (e) {
        var source_field = $(e.target).closest('[data-fieldname]').attr('data-fieldname');
        var fields_order = this.editor.form.fields_order;
        var field_index  = _(fields_order).indexOf(source_field);            
        var fields       = this.editor.form.fields;
        var field;
        do {
            if (++field_index >= fields_order.length) {
                e.preventDefault();
                return this._next();
            }
            field = fields[fields_order[field_index]];
        } while (!field.$el.is(':visible'));
        field.focus();
        return $.when();
    },

With this, if you switch name field with quantity field in sale orders lines in editable mode for example, behavior will be this:

  • Enter product code
  • Type "+" numpad key
  • Enter quantity
  • Type "Enter" numpad key
  • And so on...

It will be even better if you have set pricelist, because you just need to enter product's code and quantity and you can create a new record.

This stays in view_list_editable.js so you don't have to worry with other views behavior.

Best regards, Benjamin

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

2 follower(s)

Stats

Asked: 2/13/13, 11:10 AM
Seen: 13307 times
Last updated: 8/1/17, 3:06 PM