[IMP] override search on company object now it will pass only company related to its user company and accepted company in user prefrence

bzr revid: mra@tinyerp.com-20100209054334-7z9msubbx6rstdd1
This commit is contained in:
mra (Open ERP)
2010-02-09 11:13:34 +05:30
parent 1e704fdb89
commit 41ae526a98
+13 -3
View File
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
##############################################################################
#
#
# OpenERP, Open Source Management Solution
# Copyright (C) 2004-2009 Tiny SPRL (<http://tiny.be>).
#
@@ -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 <http://www.gnu.org/licenses/>.
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
@@ -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):
"""