From aeea721e66894a8c28704ddce11416fcdcbdadf9 Mon Sep 17 00:00:00 2001 From: Mantavya Gajjar Date: Fri, 13 Aug 2010 19:17:30 +0530 Subject: [PATCH] [FIX]: restrict the journal list in search view and list view of Journal Items bzr revid: mga@tinyerp.com-20100813134730-8113k9lix2ebrncw --- addons/account/account.py | 7 ++++++- addons/account/account_move_line.py | 9 ++++++++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/addons/account/account.py b/addons/account/account.py index b39ed2a..4c75436 100644 --- a/addons/account/account.py +++ b/addons/account/account.py @@ -716,7 +716,7 @@ class account_journal(osv.osv): result = self.write(cr, uid, [journal.id], res) return result - + def create(self, cr, uid, vals, context={}): journal_id = super(account_journal, self).create(cr, uid, vals, context) self.create_sequence(cr, uid, [journal_id], context) @@ -736,10 +736,15 @@ class account_journal(osv.osv): if not args: args = [] ids = [] + + if context.get('journal_type', False): + args += [('type','=',context.get('journal_type'))] + if name: ids = self.search(cr, user, [('code','ilike',name)]+ args, limit=limit, context=context) if not ids: ids = self.search(cr, user, [('name',operator,name)]+ args, limit=limit, context=context) + return self.name_get(cr, user, ids, context=context) def onchange_type(self, cr, uid, ids, type, currency): diff --git a/addons/account/account_move_line.py b/addons/account/account_move_line.py index effcdf9..eae81a3 100644 --- a/addons/account/account_move_line.py +++ b/addons/account/account_move_line.py @@ -842,11 +842,18 @@ class account_move_line(osv.osv): } def fields_view_get(self, cr, uid, view_id=None, view_type='form', context={}, toolbar=False, submenu=False): + journal_pool = self.pool.get('account.journal') + result = super(osv.osv, self).fields_view_get(cr, uid, view_id, view_type, context, toolbar=toolbar, submenu=submenu) if view_type != 'tree': #Remove the toolbar from the form view if view_type == 'form': result['toolbar']['action'] = [] + + #Restrict the list of journal view in search view + if view_type == 'search': + journal_list = journal_pool.name_search(cr, uid, '', [], context=context) + result['fields']['journal_id']['selection'] = journal_list return result fld = [] @@ -854,7 +861,7 @@ class account_move_line(osv.osv): flds = [] title = "Accounting Entries" #self.view_header_get(cr, uid, view_id, view_type, context) xml = '''\n\n\t''' % (title) - journal_pool = self.pool.get('account.journal') + ids = journal_pool.search(cr, uid, []) journals = journal_pool.browse(cr, uid, ids) -- 1.7.10.4