Conversation
|
we need to support both cases. This fails miserably if you construct a domain in code that uses ids. So inspect what we got, if it's a string do a name_search, and then most of the code can be unchanged |
|
...and add a test case for this too please |
|
...and write a proper commit message, as I won't squash away your work pretending it's mine |
37ec070 to
1b7b9ac
Compare
|
@NL66278 This is the pr you are looking for. |
| # https://github.com/OCA/OCB/blob/10.0/odoo/osv/expression.py#L738 | ||
| def parent_of_domain(left, ids, left_model, parent=None, prefix=''): | ||
| def parent_of_domain(left, right, left_model, parent=None, prefix=''): | ||
| if isinstance(right, unicode): |
There was a problem hiding this comment.
why don't you just assign ids the ids resulting from name_get and leave the rest unchanged?
And testing for a string in python < 3 should be done by checking for basestring
| ]) | ||
| self.assertTrue(substring_matches) | ||
| # see how _operator_parent_of deals with strings | ||
| leaf = self.env['base.domain.operator']._operator_parent_of( |
There was a problem hiding this comment.
any reason to do complicated stuff here instead of just constructing a domain as above?
| def parent_of_domain(left, ids, left_model, parent=None, prefix=''): | ||
| def parent_of_domain(left, right, left_model, parent=None, prefix=''): | ||
| if isinstance(right, basestring): | ||
| fun = left_model.name_search |
There was a problem hiding this comment.
I still think you can do here ids = [_id for _id, dummy in left_model.name_search(ids)] and leave the rest of the file unchanged
There was a problem hiding this comment.
@hbrunn I am not sure that would be a good idea. While this will work for cases in which the ids is a string (from the web client, but it will fail when the ids is actually an array of integers.
There was a problem hiding this comment.
that's why you do this only under the scope of this conditional
55bd80b to
616ee67
Compare
| def parent_of_domain(left, ids, left_model, parent=None, prefix=''): | ||
| if isinstance(right, basestring): | ||
| ids = [_id for _id, dummy in left_model.name_search(ids)] | ||
| else: |
616ee67 to
7b95ea5
Compare
hbrunn
left a comment
There was a problem hiding this comment.
please remove the part in the readme where the issue you fix is mentioned, then we can merge
7b95ea5 to
cbe78e9
Compare
Definitely I think this can be written with less code but I did the minimal changes for now.