Allow to encode Decimal in ViewSearch

issue6744
review35621002
This commit is contained in:
Cédric Krier committed 2017-09-07 21:00:28 +02:00
1 parent 3fd64d5205
commit a0010fdf13
1 file changed
+10 -1
+10 -1
View File
@@ -12,6 +12,7 @@ import re
import logging
import unicodedata
import colorsys
from decimal import Decimal
from functools import partial
from tryton.config import CONFIG
from tryton.config import TRYTON_ICON, PIXMAPS_DIR
@@ -175,6 +176,14 @@ MODELHISTORY = ModelHistory()
class ViewSearch(object):
searches = {}
def __init__(self):
class Encoder(PYSONEncoder):
def default(self, obj):
if isinstance(obj, Decimal):
return float(obj)
return super(Encoder, self).default(obj)
self.encoder = Encoder()
def load_searches(self):
try:
self.searches = rpc.execute('model', 'ir.ui.view_search',
@@ -191,7 +200,7 @@ class ViewSearch(object):
'create', [{
'model': model,
'name': name,
'domain': PYSONEncoder().encode(domain),
'domain': self.encoder.encode(domain),
}])
except RPCException:
return