Fix search for xmlrpc
Add keywords uom.category for search clause
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
#This file is part of Tryton. The COPYRIGHT file at the top level of this repository contains the full copyright notices and license terms.
|
||||
from trytond.osv import fields, OSV
|
||||
from trytond.osv import fields, OSV, OPERATORS
|
||||
from decimal import Decimal
|
||||
|
||||
STATES = {
|
||||
@@ -188,20 +188,29 @@ class Uom(OSV):
|
||||
def process_args(args):
|
||||
i = 0
|
||||
while i < len(args):
|
||||
if isinstance(args[i], list):
|
||||
process_args(args[i])
|
||||
if isinstance(args[i], tuple) \
|
||||
#add test for xmlrpc that doesn't handle tuple
|
||||
if (isinstance(args[i], tuple) \
|
||||
or (isinstance(args[i], list) and len(args[i]) > 2 \
|
||||
and args[i][1] in OPERATORS)) \
|
||||
and args[i][0] == 'category' \
|
||||
and isinstance(args[i][2], (list, tuple)) \
|
||||
and len(args[i][2]) == 2 \
|
||||
and args[i][2][1] == 'product.default_uom.category':
|
||||
and args[i][2][1] in ('product.default_uom.category',
|
||||
'uom.category'):
|
||||
if not args[i][2][0]:
|
||||
args[i] = ('id', '!=', '0')
|
||||
else:
|
||||
product = product_obj.browse(cursor, user,
|
||||
args[i][2][0], context=context)
|
||||
category_id = product.default_uom.category.id
|
||||
if args[i][2][1] == 'product.default_uom.category':
|
||||
product = product_obj.browse(cursor, user,
|
||||
args[i][2][0], context=context)
|
||||
category_id = product.default_uom.category.id
|
||||
else:
|
||||
uom = self.browse(cursor, user, args[i][2][0],
|
||||
context=context)
|
||||
category_id = uom.category.id
|
||||
args[i] = (args[i][0], args[i][1], category_id)
|
||||
elif isinstance(args[i], list):
|
||||
process_args(args[i])
|
||||
i += 1
|
||||
process_args(args)
|
||||
return super(Uom, self).search(cursor, user, args, offset=offset,
|
||||
|
||||
Reference in New Issue
Block a user