Allow to encode Decimal in ViewSearch

issue6744
review35621002
This commit is contained in:
C?dric Krier 2017-09-07 21:00:28 +02:00
parent f9581df3b7
commit 6f60a3a5c5

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