Update tab_count when using a search filter

issue5864

review27621002
This commit is contained in:
Sergi Almacellas Abellana committed 2016-10-03 09:32:56 +02:00
1 parent 8d89c49591
commit 9511a323c0
2 files changed
+41 -30

No files matched your search

+31 -24
View File
@@ -254,29 +254,7 @@ class Screen(SignalEvent):
context.update(self.context_screen.get_on_change_value())
self.new_group(context)
domain = []
if self.domain_parser and not self.parent:
if search_string is not None:
domain = self.domain_parser.parse(search_string)
else:
domain = self.search_value
self.screen_container.set_text(self.domain_parser.string(domain))
else:
domain = [('id', 'in', [x.id for x in self.group])]
if domain:
if self.domain:
domain = ['AND', domain, self.domain]
else:
domain = self.domain
if self.current_view.view_type == 'calendar':
if domain:
domain = ['AND', domain, self.current_view.current_domain()]
else:
domain = self.current_view.current_domain()
domain = self.search_domain(search_string, True)
tab_domain = self.screen_container.get_tab_domain()
if tab_domain:
domain = ['AND', domain, tab_domain]
@@ -305,16 +283,45 @@ class Screen(SignalEvent):
return ids
self.clear()
self.load(ids)
self.count_tab_domain()
return bool(ids)
def search_domain(self, search_string=None, set_text=False):
domain = []
if self.domain_parser and not self.parent:
if search_string is not None:
domain = self.domain_parser.parse(search_string)
else:
domain = self.search_value
if set_text:
self.screen_container.set_text(
self.domain_parser.string(domain))
else:
domain = [('id', 'in', [x.id for x in self.group])]
if domain:
if self.domain:
domain = ['AND', domain, self.domain]
else:
domain = self.domain
if self.current_view and self.current_view.view_type == 'calendar':
if domain:
domain = ['AND', domain, self.current_view.current_domain()]
else:
domain = self.current_view.current_domain()
return domain
def count_tab_domain(self):
def set_tab_counter(count, idx):
self.screen_container.set_tab_counter(count(), idx)
screen_domain = self.search_domain(self.screen_container.get_text())
for idx, (name, domain, count) in enumerate(
self.screen_container.tab_domain):
if not count:
continue
domain = ['AND', domain, self.domain]
domain = ['AND', domain, screen_domain]
set_tab_counter(lambda: None, idx)
RPCExecute('model', self.model_name,
'search_count', domain, context=self.context,
callback=functools.partial(set_tab_counter, idx=idx))
@@ -410,12 +410,16 @@ class ScreenContainer(object):
return
label = self.tab_counter[idx]
tooltip = common.Tooltips()
tooltip.set_tip(label, '%d' % count)
fmt = '(%d)'
if count > 99:
fmt = '(%d+)'
count = 99
label.set_label(fmt % count)
if count is None:
label.set_label('')
tooltip.set_tip(label, '')
else:
tooltip.set_tip(label, '%d' % count)
fmt = '(%d)'
if count > 99:
fmt = '(%d+)'
count = 99
label.set_label(fmt % count)
def match_selected(self, completion, model, iter):
def callback():