Allow to encode Decimal in ViewSearch
issue6744 review35621002
This commit is contained in:
1 parent
3fd64d5205
commit
a0010fdf13
1 file changed
+10
-1
+10
-1
@@ -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
|
||||
|
||||
Reference in new issue
Block a user