[7.0] domain on many2many fields and selection widget

Bug #1214469 reported by Davide Corio
12
This bug affects 2 people
Affects Status Importance Assigned to Milestone
Odoo Server (MOVED TO GITHUB)
New
Undecided
Unassigned

Bug Description

I noticed that, when using widget="selection" on many2many fields, domain filters don't work and raise:

Traceback (most recent call last):
  File "/home/enlightx/Development/OpenERP/7.0/server/openerp/tools/safe_eval.py", line 241, in safe_eval
    return eval(test_expr(expr, _SAFE_OPCODES, mode=mode), globals_dict, locals_dict)
  File "", line 1, in <module>
NameError: name 'the_attribute' is not defined

where "the_attribute" can be:

- a field
- parent
- context

summary: - domain on many2many fields and selection widget
+ [7.0] domain on many2many fields and selection widget
Revision history for this message
Davide Corio (enlightx-deactivatedaccount) wrote :

it actually happens also with many2one fields

Revision history for this message
Raphaël Valyi - http://www.akretion.com (rvalyi) wrote : Re: [Bug 1214469] Re: [7.0] domain on many2many fields and selection widget

Hello Davide,

in fact at least in the past, it was said that not having domains on the
selection widget was a feature and not a bug given that the selectable
collection was statically pre-loaded on the server side without Ajax (we
would still had static domains, still). In versions inferior to v7,
selections was a way to save user clicks. in v7 instead, this is less true
as when the 1st items of m2o widgets are pre-loaded before user clicks. So
in any case in v7, many selection widgets can be replaced by standard m2o
widget. I don't know if that invalidates the bug or not, I'll let the
official guys comment on it.*

Regards.

On Tue, Aug 20, 2013 at 3:47 PM, Davide Corio <email address hidden> wrote:

> it actually happens also with many2one fields
>
> --
> You received this bug notification because you are a member of OpenERP
> Drivers, which is subscribed to OpenERP Server.
> https://bugs.launchpad.net/bugs/1214469
>
> Title:
> [7.0] domain on many2many fields and selection widget
>
> Status in OpenERP Server:
> New
>
> Bug description:
> I noticed that, when using widget="selection" on many2many fields,
> domain filters don't work and raise:
>
> Traceback (most recent call last):
> File
> "/home/enlightx/Development/OpenERP/7.0/server/openerp/tools/safe_eval.py",
> line 241, in safe_eval
> return eval(test_expr(expr, _SAFE_OPCODES, mode=mode), globals_dict,
> locals_dict)
> File "", line 1, in <module>
> NameError: name 'the_attribute' is not defined
>
> where "the_attribute" can be:
>
> - a field
> - parent
> - context
>
> To manage notifications about this bug go to:
> https://bugs.launchpad.net/openobject-server/+bug/1214469/+subscriptions
>

Revision history for this message
Davide Corio (enlightx-deactivatedaccount) wrote :

just found the code that does what you mentioned.

since choosing the selection widget is often driven by the need of avoiding the "creating and edit" feature, it's still possible to use one of the "unofficial" tricks we can use to hide this menu, but i still don't understand the technical reason why it's not possible to preload AND filter the results since the domain con be specified via python hence server-side. But i'm probably missing the point here.

Revision history for this message
Davide Corio (enlightx-deactivatedaccount) wrote :

nevermind, the reason is clear. and the domain specified in the field definition cannot be evaluated server-side if it implies dynamic attibutes you can manipulate client-side

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.