Jay Vora (OpenERP) has proposed merging 
lp:~openerp-dev/openobject-addons/6.0-opw-16636-jvo into 
lp:openobject-addons/6.0.

Requested reviews:
  OpenERP Core Team (openerp)

For more details, see:
https://code.launchpad.net/~openerp-dev/openobject-addons/6.0-opw-16636-jvo/+merge/72156
-- 
https://code.launchpad.net/~openerp-dev/openobject-addons/6.0-opw-16636-jvo/+merge/72156
Your team OpenERP R&D Team is subscribed to branch 
lp:~openerp-dev/openobject-addons/6.0-opw-16636-jvo.
=== modified file 'analytic/analytic.py'
--- analytic/analytic.py	2011-08-04 13:36:32 +0000
+++ analytic/analytic.py	2011-08-19 09:42:24 +0000
@@ -217,16 +217,31 @@
         if partner:
             res['value']['partner_id'] = partner
         return res
+    
+    def search(self, cr, user, args, offset=0, limit=None, order=None, context=None, count=False):
+        if context is None:
+            context = {}
+        if context.get('current_model') == 'project.project':
+            cr.execute("select analytic_account_id from project_project")
+            project_ids = [x[0] for x in cr.fetchall()]
+            args += [('id', 'in',project_ids)]
+        return super(account_analytic_account, self).search(cr, user, args, offset=offset, limit=limit, order=order,
+            context=context, count=count)
 
     def name_search(self, cr, uid, name, args=None, operator='ilike', context=None, limit=100):
         if not args:
-            args=[]
+            args = []
         if context is None:
             context={}
-        if context.get('current_model') == 'project.project':
-            cr.execute("select analytic_account_id from project_project")
-            project_ids = [x[0] for x in cr.fetchall()]
-            return self.name_get(cr, uid, project_ids, context=context)
+#        if context.get('current_model') == 'project.project':
+#            cr.execute("select analytic_account_id from project_project ")
+#            project_ids = [x[0] for x in cr.fetchall()]
+#            # We cannot return here with normal project_ids, the following process also has to be followed.
+#            # The search should consider the name inhere, earlier it was just bypassing it.
+#            # Hence, we added the args and let the below mentioned procedure do the trick
+#            # Let the search method manage this.
+#            args += [('id', 'in', project_ids)]
+#            return self.name_get(cr, uid, project_ids, context=context)
         account = self.search(cr, uid, [('code', '=', name)]+args, limit=limit, context=context)
         if not account:
             account = self.search(cr, uid, [('name', 'ilike', '%%%s%%' % name)]+args, limit=limit, context=context)

_______________________________________________
Mailing list: https://launchpad.net/~openerp-dev-gtk
Post to     : [email protected]
Unsubscribe : https://launchpad.net/~openerp-dev-gtk
More help   : https://help.launchpad.net/ListHelp

Reply via email to