diff --git a/bin/addons/base/res/res_company.py b/bin/addons/base/res/res_company.py index 7b751eb7c20..4c5aca9b84b 100644 --- a/bin/addons/base/res/res_company.py +++ b/bin/addons/base/res/res_company.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- ############################################################################## -# +# # OpenERP, Open Source Management Solution # Copyright (C) 2004-2009 Tiny SPRL (). # @@ -15,7 +15,7 @@ # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License -# along with this program. If not, see . +# along with this program. If not, see . # ############################################################################## @@ -86,7 +86,17 @@ class res_company(osv.osv): 'currency_id': fields.many2one('res.currency', 'Currency', required=True), 'currency_ids': fields.one2many('res.currency', 'company_id', 'Currency'), 'user_ids': fields.many2many('res.users', 'res_company_users_rel', 'cid', 'user_id', 'Accepted Users') - } + } + + def search(self, cr, user, args, offset=0, limit=None, order=None, + context=None, count=False): + if context and context.has_key('prefence_company') and context['prefence_company']: + cmp_ids = [] + data_user = self.pool.get('res.users').browse(cr, user, [user], context=context) + map(lambda x: cmp_ids.append(x.id), data_user[0].company_ids) + return [data_user[0].company_id.id] + cmp_ids + return super(res_company, self).search(cr, user, args, offset=offset, limit=limit, order=order, + context=context, count=count) def _company_default_get(self, cr, uid, object=False, field=False, context=None): """