From 7a8f2011fabd66b5e15b380716dceecbeecf2c57 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 --- purchase.py | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/purchase.py b/purchase.py index e3b360861c..80db0a5395 100644 --- a/purchase.py +++ b/purchase.py @@ -50,17 +50,15 @@ def get_shipments_returns(model_name): def search_shipments_returns(model_name): "Search on shipments or returns" def method(self, name, clause): - nested = clause[0].lstrip(name) - if nested: - return [('lines.moves.shipment' + nested,) - + tuple(clause[1:3]) + (model_name,) + tuple(clause[3:])] - else: + _, operator, operand, *extra = clause + nested = clause[0][len(name):] + if not nested: if isinstance(clause[2], str): - target = 'rec_name' + nested = '.rec_name' else: - target = 'id' - return [('lines.moves.shipment.' + target,) - + tuple(clause[1:3]) + (model_name,)] + nested = '.id' + return [('lines.moves.shipment' + nested, + operator, operand, model_name, *extra)] return classmethod(method)