Use length of field name instead of lstrip to get nested part of clause

issue11714
review437381003
This commit is contained in:
Cédric Krier
2022-10-01 15:35:33 +02:00
parent a48fb19e8d
commit c44e9fd921
2 changed files with 8 additions and 8 deletions
+6 -6
View File
@@ -19,22 +19,22 @@ class Party(MarketingAutomationMixin, metaclass=PoolMeta):
@classmethod
def search_marketing_party(cls, name, clause):
operand, operator, value = clause[:3]
nested = operand.lstrip(name)
_, operator, operand, *extra = clause[:3]
nested = clause[0][len(name):]
if not nested:
if operator.endswith('where'):
query = cls.search(value, order=[], query=True)
query = cls.search(operand, order=[], query=True)
if operator.startswith('not'):
return [('id', 'not in', query)]
else:
return [('id', 'in', query)]
elif isinstance(value, str):
elif isinstance(operand, str):
nested = 'rec_name'
else:
nested = 'id'
else:
nested = nested.lstrip('.')
return [(nested,) + tuple(clause[1:])]
nested = nested[1:]
return [(nested, operator, operand, *extra)]
class PartyUnsubscribedScenario(ModelSQL):
+2 -2
View File
@@ -14,5 +14,5 @@ class Sale(MarketingAutomationMixin, metaclass=PoolMeta):
@classmethod
def search_marketing_party(cls, name, clause):
nested = clause[0].lstrip(name)
return [('party' + nested,) + tuple(clause[1:])]
nested = clause[0][len(name):]
return [('party' + nested, *clause[1:])]