mirror of
https://github.com/NaN-tic/tryton-gtk2.git
synced 2023-12-14 03:12:58 +01:00
Allow to encode Decimal in ViewSearch
issue6744 review35621002
This commit is contained in:
parent
f9581df3b7
commit
6f60a3a5c5
1 changed files with 10 additions and 1 deletions
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue