[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
This commit is contained in:
Denis Ledoux 2014-03-04 18:52:31 +01:00
parent 1761704af2
commit a76cedfee3
2 changed files with 6 additions and 7 deletions

View File

@ -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):
"""

View File

@ -282,7 +282,7 @@
<group name="preferences" col="4">
<field name="lang" readonly="0"/>
<field name="tz" readonly="0"/>
<field name="company_id" widget="selection" readonly="0"
<field name="company_id" options="{'no_create': True}" readonly="0"
groups="base.group_multi_company"/>
</group>
<group string="Email Preferences">