Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ADD] New module <web_decimal_numpad_dot> #57

Open
wants to merge 4 commits into
base: 8.0
Choose a base branch
from

Conversation

oihane
Copy link
Contributor

@oihane oihane commented Jun 4, 2015

No description provided.

@omar7r
Copy link

omar7r commented Nov 5, 2015

Hola Ohiane,

¿Este módulo os funciona?, a mi me daba error e hice un cambio en el evento que se vigila, te pego el código con el que me funciona.

(function() {

var instance = openerp;

instance.web.form.FieldFloat = instance.web.form.FieldChar.extend({
    is_field_number: true,
    widget_class: 'oe_form_field_float',
    events: {
        "keypress": "floatKeypress",
    },
    floatKeypress: function(e){
        if(e.keyCode == '46' || e.charCode == '46'){
            //Cancel the keypress
            e.preventDefault();
            // Add the comma to the value of the input field
             this.$("input").val(this.$("input").val() + ',');
         }
    },
});

})();

Un saludo.

@oihane
Copy link
Contributor Author

oihane commented Nov 6, 2015

@omar7r en realidad no llego a funcionar del todo, probaré y si funciona lo subo 😉
Gracias por el reporte

@oihane
Copy link
Contributor Author

oihane commented Nov 12, 2015

@omar7r probado, pero no hace lo que yo pretendía, si no que cambia el punto por la coma en TODOS los casos, mi intención era que el punto del teclado numérico funcionase como coma.

Por lo demás muchas gracias serviría así.

@wim-a
Copy link

wim-a commented Dec 8, 2015

We installed the module web_decimal_numpad_dot last week. For data entry by the users, this works great.

But we found an issue with displaying the data.

We have set the decimal accuracy for f.e. “Product Price” to 4 digits. When this module is installed, it always only shows 2 digits for the product price. As soon as I uninstall the module, it’s showing again 4 digits.

@pedrobaeza
Copy link
Member

@oihane, please check this one.

@RoelAdriaans
Copy link

Can confirm @wim-a 's issue.

Another thing, when the default value is 0,00, installing the module makes the field empty.
For example, adding a line in a quotation, by default it shows 0,00 for the price. If we install this module it shows nothing.

If we they say, this product is 0,00 and save it it works. When we edit the line again the price field is empty again.

  • Language = Dutch
  • Separator Format = [3,0]
  • Decimal Separator = , (Comma)
  • Thousands Separator = . (Dot)

@omar7r
Copy link

omar7r commented Dec 14, 2015

Hi,

Try this new source code, because with the original you overwrite the default functionalities of float widget:

(function() {

var instance = openerp;

instance.web.form.FieldFloat = instance.web.form.FieldFloat.extend({
    render_value: function() {
        var self = this;
        this._super();
        if (!this.get('readonly')){
            this.$el.find('input').on('keypress', this.floatKeypress.bind(this));
        }
    },
    floatKeypress: function(e){
        if(e.keyCode == '46' || e.charCode == '46'){
            //Cancel the keypress
            e.preventDefault();
            // Add the comma to the value of the input field
             this.$("input").val(this.$("input").val() + ',');
         }
    },
});

})();

@wim-a
Copy link

wim-a commented Dec 15, 2015

Hello,

I tested it. This works great now.

Thanks a lot.

Best regards,

Wim

From: omar7r [mailto:[email protected]]
Sent: Monday, December 14, 2015 9:24 PM
To: odoomrp/odoomrp-utils [email protected]
Cc: Wim Audenaert [email protected]
Subject: Re: [odoomrp-utils] [ADD] New module <web_decimal_numpad_dot> (#57)

Hi,

Try this new source code, because with the original you overwrite the default functionalities of float widget:

(function() {

var instance = openerp;

instance.web.form.FieldFloat = instance.web.form.FieldFloat.extend({
render_value: function() {
var self = this;
this._super();
if (!this.get('readonly')){
this.$el.find('input').on('keypress', this.floatKeypress.bind(this));
}
},
floatKeypress: function(e){
console.log("Inside");
console.log(e.keyCode);
if(e.keyCode == '46' || e.charCode == '46'){
//Cancel the keypress
e.preventDefault();
// Add the comma to the value of the input field
this.$("input").val(this.$("input").val() + ',');
}
},
});

})();


Reply to this email directly or view it on GitHubhttps://github.com//pull/57#issuecomment-164548700.

@wim-a
Copy link

wim-a commented Dec 15, 2015

Hello,

I tested it with the new code. This works great now. Thanks a lot.

Best regards,
Wim

@RoelAdriaans
Copy link

This breaks things for the English user, I can no longer enter 1.5 or 1,5.
Not with de decimal keypad, or the default , of . with the keys.
This is because English uses the . (dot) as decimal separator and it now completely replaced with a , .

But, the problem with empty fields is fixed :)

@RoelAdriaans
Copy link

Solved it by doing the replace only when the decimal point is an , :

if ((e.keyCode == '46' || e.charCode == '46') && instance.web._t.database.parameters.decimal_point == ',') {

Added check after the keycode is the right one, but speed doesn't seem to matter.

@oihane
Copy link
Contributor Author

oihane commented Dec 16, 2015

Changed again, it was supposed to do the replacement only when pressing the dot from de numpad, but it seems that keypress does not distinguish between simple dot and numpad dot

@acysos
Copy link

acysos commented Dec 30, 2015

Great work Oihane.

I have detected a bug. When you put a product in the line, a put the price it put two or more commas instead of one. I have replicate the bug in sale order, purchase order and invoice.

Also I have some controls with console and I have detect when you push the keys of the float field the function floatKeypress receive the key two or more times, not only the dot key also the number keys.

I think that the problem is when the product_id change it open two capture keys events or browser cache. I go to investigate but if somebody have any idea, it can help.

Greetings

@wim-a
Copy link

wim-a commented Jan 3, 2016

Hello,

First I want to wish you all a happy new year.

We have the same problem. I don’t think that it has to do with product_id change, as it also happens on screens where no product_id is defined. I have been looking further into it, and it looks to me that it depends on the length of the keypress. With some users, it almost never happens, and other users have it very frequently, even when both users use the same screens.

Best regards,

Wim

From: Odoo - OpenERP - Acysos S.L. [mailto:[email protected]]
Sent: Wednesday, December 30, 2015 5:57 PM
To: odoomrp/odoomrp-utils [email protected]
Cc: Wim Audenaert [email protected]
Subject: Re: [odoomrp-utils] [ADD] New module <web_decimal_numpad_dot> (#57)

Great work Oihane.

I have detected a bug. When you put a product in the line, a put the price it put two or more commas instead of one. I have replicate the bug in sale order, purchase order and invoice.

Also I have some controls with console and I have detect when you push the keys of the float field the function floatKeypress receive the key two or more times, not only the dot key also the number keys.

I think that the problem is when the product_id change it open two capture keys events. I go to investigate but if somebody have any idea, it can help.

Greetings


Reply to this email directly or view it on GitHubhttps://github.com//pull/57#issuecomment-168033668.

@wim-a
Copy link

wim-a commented Jan 14, 2016

Is there any news about this bug?

Best regards,

Wim

@wim-a
Copy link

wim-a commented Jan 14, 2016

Looks that I resolved the problem. I'm not an experienced js developer, but I have changed the floatKeyPress function as follows, and it looks to work well..

    floatKeypress: function(e){
        if(e.keyCode == '46' || e.charCode == '46'){
            //Cancel the keypress
            e.preventDefault();
            // Check last entered character
            if(this.el.firstElementChild.value.slice(-1)!=','){
                // Add the comma to the value of the input field
                this.$("input").val(this.$("input").val() + ',');
            }
        } else {
            if(e.keyCode == '44' || e.charCode == '44'){
                // Check last entered character
                if(this.el.firstElementChild.value.slice(-1)==','){
                    //Cancel the keypress
                    e.preventDefault();
                }
            }
        }
    },

@oihane
Copy link
Contributor Author

oihane commented Jan 14, 2016

@wim-a but using that code if module is installed and a user is working in other language that uses . as decimal point and no , it will not be able to work properly.

My idea was to change this functionality only using the dot of the num pad, but I didn't manage to do it so, many other things to do, this is the last of the list.

Thanks for your contribution.

@wim-a
Copy link

wim-a commented Jan 14, 2016

Yes, oihane, I agree with what you write there. This code should be modified so that it also works in other languages.

My highest priority with this issue was to solve it for my own users. Some of them have this problem many times per day. I already wanted to share how I changed it so that other customers, also using a decimal comma and having the same problem, can resolve it until there is a final solution working for all languages.

@liebana
Copy link

liebana commented Mar 18, 2016

What's the status of this? Can somebody summarize?

@hernanpinzong
Copy link

Buen Dia, me podrian ayudar a resolver como puedo eliminar de los precios de los productos los dos ceros decimales sobres ejemplo 15.000,00 quisiera que no saliera estos dos digitos ,00 .

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants