From d5ff501ccc854c32d0c1a58f99e6ccf67f9d79ae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Sat, 16 Nov 2013 19:00:14 +0100 Subject: [PATCH] Search limit must be int Since usage of python-sql limit is enforced to only integer. issue3484 review1691002 --- tryton/config.py | 4 +++- tryton/gui/window/limit.py | 10 +++++----- tryton/gui/window/view_form/model/record.py | 2 +- tryton/gui/window/view_form/screen/screen.py | 2 +- 4 files changed, 10 insertions(+), 8 deletions(-) diff --git a/tryton/config.py b/tryton/config.py index ac9763de4e..a20aba8f62 100644 --- a/tryton/config.py +++ b/tryton/config.py @@ -155,7 +155,9 @@ class ConfigManager(object): elif value.lower() == 'false': value = False if section == 'client' and name == 'limit': - value = float(value) + # First convert to float to be backward compatible with old + # configuration + value = int(float(value)) self.config[section + '.' + name] = value return True diff --git a/tryton/gui/window/limit.py b/tryton/gui/window/limit.py index b0501e8131..af4797a09d 100644 --- a/tryton/gui/window/limit.py +++ b/tryton/gui/window/limit.py @@ -27,11 +27,11 @@ class Limit(object): self.win.vbox.pack_start(gtk.HSeparator()) hbox = gtk.HBox(spacing=3) hbox.pack_start(gtk.Label(_('Limit:')), expand=True, fill=True) - self.spin_limit = gtk.SpinButton(climb_rate=1, digits=0) + adjustment = gtk.Adjustment(value=CONFIG['client.limit'], + lower=1, upper=sys.maxint, step_incr=10, page_incr=100) + self.spin_limit = gtk.SpinButton(adjustment, climb_rate=1, digits=0) self.spin_limit.set_numeric(False) - self.spin_limit.set_adjustment(gtk.Adjustment( - value=CONFIG['client.limit'], lower=1, upper=sys.maxint, - step_incr=10, page_incr=100)) + self.spin_limit.set_activates_default(True) hbox.pack_start(self.spin_limit, expand=True, fill=True) self.win.vbox.pack_start(hbox, expand=True, fill=True) @@ -41,7 +41,7 @@ class Limit(object): 'Run the window' res = self.win.run() if res == gtk.RESPONSE_OK: - CONFIG['client.limit'] = self.spin_limit.get_value() + CONFIG['client.limit'] = self.spin_limit.get_value_as_int() CONFIG.save() self.parent.present() self.win.destroy() diff --git a/tryton/gui/window/view_form/model/record.py b/tryton/gui/window/view_form/model/record.py index e90dc96811..a2aeb21f55 100644 --- a/tryton/gui/window/view_form/model/record.py +++ b/tryton/gui/window/view_form/model/record.py @@ -73,7 +73,7 @@ class Record(SignalEvent): record_context = self.context_get() if loading == 'eager': - limit = int(CONFIG['client.limit']) + limit = CONFIG['client.limit'] if not self.parent: # If not a children no need to load too much limit = int(limit / len(fnames)) diff --git a/tryton/gui/window/view_form/screen/screen.py b/tryton/gui/window/view_form/screen/screen.py index b290951e40..37923e3e8d 100644 --- a/tryton/gui/window/view_form/screen/screen.py +++ b/tryton/gui/window/view_form/screen/screen.py @@ -53,7 +53,7 @@ class Screen(SignalEvent): if domain is None: domain = [] - self.limit = limit or int(CONFIG['client.limit']) + self.limit = limit or CONFIG['client.limit'] self.offset = 0 super(Screen, self).__init__()