Reviewers: ,


Please review this at http://codereview.tryton.org/438001/

Affected files:
  M CHANGELOG
  M tryton/common/domain_inversion.py
  M tryton/gui/window/view_form/model/field.py


Index: CHANGELOG
===================================================================

--- a/CHANGELOG
+++ b/CHANGELOG
@@ -1,3 +1,4 @@
+* Manage tuple on Reference
 * Make Import/Export Data no-modal
 * Deactivate switch view button when there is only 1 view
 * Manage create/delete field access

Index: tryton/common/domain_inversion.py
===================================================================

--- a/tryton/common/domain_inversion.py
+++ b/tryton/common/domain_inversion.py
@@ -68,6 +68,18 @@
             context_field = datetime.datetime.min
         else:
             context_field = datetime.date.min
+    if (isinstance(context_field, basestring)
+            and isinstance(value, (list, tuple))):
+        try:
+            value = '%s,%s' % value
+        except TypeError:
+            pass
+    elif (isinstance(context_field, (list, tuple))
+            and isinstance(value, basestring)):
+        try:
+            context_field = '%s,%s' % context_field
+        except TypeError:
+            pass
     return OPERATORS[operand](context_field, value)


@@ -470,6 +482,18 @@
     assert not eval_domain(domain, {'x': 5})
     assert not eval_domain(domain, {'x': 11})

+    domain = [['x', '=', 'test,1']]
+    assert eval_domain(domain, {'x': ('test', 1)})
+    assert eval_domain(domain, {'x': 'test,1'})
+    assert not eval_domain(domain, {'x': ('test', 2)})
+    assert not eval_domain(domain, {'x': 'test,2'})
+
+    domain = [['x', '=', ('test', 1)]]
+    assert eval_domain(domain, {'x': ('test', 1)})
+    assert eval_domain(domain, {'x': 'test,1'})
+    assert not eval_domain(domain, {'x': ('test', 2)})
+    assert not eval_domain(domain, {'x': 'test,2'})
+

 def test_localize():
     domain = [['x', '=', 5]]

Index: tryton/gui/window/view_form/model/field.py
===================================================================

--- a/tryton/gui/window/view_form/model/field.py
+++ b/tryton/gui/window/view_form/model/field.py
@@ -811,6 +811,8 @@

     def set_client(self, record, value, force_change=False):
         if value:
+            if isinstance(value, basestring):
+                value = value.split(',')
             ref_model, ref_id = value
             if isinstance(ref_id, (tuple, list)):
                 ref_id, rec_name = ref_id



--
[email protected] mailing list

Reply via email to