From c44e9fd9219de8db851815a61ffc1eb61852ad7c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Sat, 1 Oct 2022 15:35:33 +0200 Subject: [PATCH] Use length of field name instead of lstrip to get nested part of clause issue11714 review437381003 --- party.py | 12 ++++++------ sale.py | 4 ++-- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/party.py b/party.py index 06f4f01101..0d8d3cfa21 100644 --- a/party.py +++ b/party.py @@ -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): diff --git a/sale.py b/sale.py index 0417943ecf..6b98ef4eb3 100644 --- a/sale.py +++ b/sale.py @@ -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:])]