openerp-community team mailing list archive
-
openerp-community team
-
Mailing list archive
-
Message #03366
lp:~camptocamp/openerp-product-attributes/7.0-literal_eval-domain into lp:openerp-product-attributes
Guewen Baconnier @ Camptocamp has proposed merging lp:~camptocamp/openerp-product-attributes/7.0-literal_eval-domain into lp:openerp-product-attributes.
Commit message:
[FIX] an empty domain '[]' is eval'ed as True and is always used
Requested reviews:
Product Core Editors (product-core-editors)
For more details, see:
https://code.launchpad.net/~camptocamp/openerp-product-attributes/7.0-literal_eval-domain/+merge/188573
The domain is a string and is equal to '[]' when no domain is explicitely set.
Thus, the condition is always True-ish and the domain using the option ids is never built.
--
https://code.launchpad.net/~camptocamp/openerp-product-attributes/7.0-literal_eval-domain/+merge/188573
Your team OpenERP Community is subscribed to branch lp:openerp-product-attributes.
=== modified file 'base_custom_attributes/custom_attributes.py'
--- base_custom_attributes/custom_attributes.py 2013-09-27 19:24:53 +0000
+++ base_custom_attributes/custom_attributes.py 2013-10-01 12:20:12 +0000
@@ -20,6 +20,7 @@
# #
###############################################################################
+import ast
from openerp.osv import orm, fields
from openerp.osv.osv import except_osv
from openerp.tools.translate import _
@@ -119,7 +120,12 @@
kwargs['nolabel'] = "1"
if attribute.ttype in ['many2one', 'many2many']:
if attribute.relation_model_id:
- if attribute.domain:
+ # attribute.domain is a string, it may be an empty list
+ try:
+ domain = ast.literal_eval(attribute.domain)
+ except ValueError:
+ domain = None
+ if domain:
kwargs['domain'] = attribute.domain
else:
ids = [op.value_ref.id for op in attribute.option_ids]
References