Skip to content
Snippets Groups Projects
Commit 8dbd1efe authored by Géry Debongnie's avatar Géry Debongnie
Browse files

[FIX] web: issue with field named "length"


The underscore (_) library has a bug in which the _.each method does not
work with object which contains a "length" property. This is because it
does look for that key and if it is a number, it will assume that it is
an array with that length value.  Nicely done...

If that length value is set to 0, then it will just do nothing, since it
thinks that it is dealing with an empty array.

Note that if the value is set to an object, _.each is smart enough to
notice that it cannot be an array, and will do the correct thing in this
case.

Usually, our _.each calls are safe, since we usually iterate on arrays,
or on object with safe keys, or on object with values that cannot be a
number.

But there was 2 unsafe calls in basic_model, which leads to strange
bugs: some code is skipped, and the form view is then confused.  The
motivation for this fix is the fact that onchanges are not applied at
all, if there is a length field set to 0.

To fix this, we can just avoid using _.each.  Note to every Odoo JS
developers reading this: new Odoo code should avoid using the _ and $
libraries, because we do not really need them, and we want to keep our
dependencies to the strict mininum.

OPW: #2465808
closes odoo/odoo#66126

closes odoo/odoo#67138

Signed-off-by: default avatarAaron Bohy (aab) <aab@odoo.com>
parent 2d7f45e7
No related branches found
No related tags found
No related merge requests found
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment