Skip to content

Commit

Permalink
[FIX] project: correct name_search for analytic accounts, use args, n…
Browse files Browse the repository at this point in the history
…ame, limit and context

bzr revid: mat@openerp.com-20130828141123-ws38n7353f717not
  • Loading branch information
mart-e committed Aug 28, 2013
1 parent 57818bb commit cf45a9f
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
4 changes: 0 additions & 4 deletions addons/analytic/analytic.py
Original file line number Diff line number Diff line change
Expand Up @@ -295,10 +295,6 @@ def name_search(self, cr, uid, name, args=None, operator='ilike', context=None,
args=[]
if context is None:
context={}
if context.get('current_model') == 'project.project':
project_obj = self.pool.get("account.analytic.account")
project_ids = project_obj.search(cr, uid, args)
return self.name_get(cr, uid, project_ids, context=context)
if name:
account_ids = self.search(cr, uid, [('code', '=', name)] + args, limit=limit, context=context)
if not account_ids:
Expand Down
12 changes: 12 additions & 0 deletions addons/project/project.py
Original file line number Diff line number Diff line change
Expand Up @@ -1342,6 +1342,18 @@ def unlink(self, cr, uid, ids, *args, **kwargs):
raise osv.except_osv(_('Warning!'), _('Please delete the project linked with this account first.'))
return super(account_analytic_account, self).unlink(cr, uid, ids, *args, **kwargs)

def name_search(self, cr, uid, name, args=None, operator='ilike', context=None, limit=100):
if args is None:
args = []
if context is None:
context={}
if context.get('current_model') == 'project.project':
project_ids = self.search(cr, uid, args + [('name', operator, name)], limit=limit, context=context)
return self.name_get(cr, uid, project_ids, context=context)

return super(account_analytic_account, self).name_search(cr, uid, name, args=args, operator=operator, context=context, limit=limit)


class project_project(osv.osv):
_inherit = 'project.project'
_defaults = {
Expand Down

0 comments on commit cf45a9f

Please sign in to comment.