From d670268ff93bb17518876aabdab5b6bd53ee6448 Mon Sep 17 00:00:00 2001 From: Gael LE GUEDARD Date: Wed, 27 Feb 2013 16:58:52 +0100 Subject: [PATCH] Add missing context on Selection widget Add context on domain cache in the widget selection. Add context on search_read function in selection widget. issue2967 review655003 --- tryton/common/selection.py | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/tryton/common/selection.py b/tryton/common/selection.py index 419cbe820a..ed53901377 100644 --- a/tryton/common/selection.py +++ b/tryton/common/selection.py @@ -47,22 +47,25 @@ class SelectionMixin(object): self.init_selection(tuple(key)) else: domain = field.domain_get(record) - if str(domain) in self._domain_cache: - self.selection = self._domain_cache[str(domain)] - self._last_domain = domain - if domain == self._last_domain: + context = record[self.field_name].context_get(record) + domain_cache_key = str(domain) + str(context) + if domain_cache_key in self._domain_cache: + self.selection = self._domain_cache[domain_cache_key] + self._last_domain = (domain, context) + if (domain, context) == self._last_domain: return try: result = RPCExecute('model', self.attrs['relation'], - 'search_read', domain, 0, None, None, ['rec_name']) + 'search_read', domain, 0, None, None, ['rec_name'], + context=context) except RPCException: result = False if isinstance(result, list): selection = [(x['id'], x['rec_name']) for x in result] selection.append((None, '')) - self._last_domain = domain - self._domain_cache[str(domain)] = selection + self._last_domain = (domain, context) + self._domain_cache[domain_cache_key] = selection else: selection = [] self._last_domain = None