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

issue11714
review437381003
This commit is contained in:
Cédric Krier committed 2022-10-01 15:35:33 +02:00
1 parent 088c7d3bc9
commit 7a8f2011fa
1 file changed
+7 -9
+7 -9
View File
@@ -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)