From a76cedfee3474af3087a60aae5ba5164d98db9fe Mon Sep 17 00:00:00 2001 From: Denis Ledoux Date: Tue, 4 Mar 2014 18:52:31 +0100 Subject: [PATCH] [FIX] base: widget selection changed its behavior in saas-3 _search overwritten in res_company to allow user to change of company among its allowed companies is not usefull anymore, name_search is now the method to overwrite. moreover, widget selection replaced by options no_create in user preferenes view, to allow typing in the many2one(for searching purpose) without having the option to create a new company or edit. bzr revid: dle@openerp.com-20140304175231-ojhzqecrdkjg2w52 --- openerp/addons/base/res/res_company.py | 11 +++++------ openerp/addons/base/res/res_users_view.xml | 2 +- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/openerp/addons/base/res/res_company.py b/openerp/addons/base/res/res_company.py index 91a77997598..f1d2e6e9c55 100644 --- a/openerp/addons/base/res/res_company.py +++ b/openerp/addons/base/res/res_company.py @@ -208,20 +208,19 @@ class res_company(osv.osv): res['value'] = {'currency_id': currency_id} return res - def _search(self, cr, uid, args, offset=0, limit=None, order=None, - context=None, count=False, access_rights_uid=None): + def name_search(self, cr, uid, name='', args=None, operator='ilike', context=None, limit=100): if context is None: context = {} - if context.get('user_preference'): + if context.pop('user_preference', None): # We browse as superuser. Otherwise, the user would be able to # select only the currently visible companies (according to rules, # which are probably to allow to see the child companies) even if # she belongs to some other companies. user = self.pool.get('res.users').browse(cr, SUPERUSER_ID, uid, context=context) cmp_ids = list(set([user.company_id.id] + [cmp.id for cmp in user.company_ids])) - return cmp_ids - return super(res_company, self)._search(cr, uid, args, offset=offset, limit=limit, order=order, - context=context, count=count, access_rights_uid=access_rights_uid) + uid = SUPERUSER_ID + args = (args or []) + [('id', 'in', cmp_ids)] + return super(res_company, self).name_search(cr, uid, name=name, args=args, operator=operator, context=context, limit=limit) def _company_default_get(self, cr, uid, object=False, field=False, context=None): """ diff --git a/openerp/addons/base/res/res_users_view.xml b/openerp/addons/base/res/res_users_view.xml index ba603c7a0f0..8a3f372af7a 100644 --- a/openerp/addons/base/res/res_users_view.xml +++ b/openerp/addons/base/res/res_users_view.xml @@ -282,7 +282,7 @@ -