Comment 4 for bug 290274

Revision history for this message
Joël Grand-Guillaume @ camptocamp (jgrandguillaume-c2c) wrote : Re: [Bug 290274] Re: Name_search based on context don't work in o2m

Hi,

It's ok for the call wich pass right the context now, but we still
have a problem I described here:

https://bugs.launchpad.net/openobject-client-web/+bug/296328

I found a solution (not sure it's the right one) and give a patch for.

Thanks to have a look and give me some feed-back.

Regards,

Joël

Le 6 nov. 08 à 14:14, Amit Mendapara a écrit :

> I have fixed the problem in trunk as well as branch 4.2. Please
> confirm
> whether it has solved your problem or not.
>
> ** Changed in: openobject-client-web
> Assignee: (unassigned) => Amit Mendapara (mendapara-amit)
> Status: New => In Progress
>
> --
> Name_search based on context don't work in o2m
> https://bugs.launchpad.net/bugs/290274
> You received this bug notification because you are a direct subscriber
> of the bug.
>
> Status in OpenObject Web Client: In Progress
>
> Bug description:
> Name_search based on context don't work in o2m field.
>
> If you add context tag on a tree view in o2m filed, this context is
> not pass to the name_search function. This is bad, cause it' very
> useful. You can for exemple make a filter on "activity" based on
> selected "account" in the line...
>
> An exemple:
>
> Here the field view definition in the tree part of o2m:
>
> <field name="activity" context="account_id=account_id"/>
>
> Here the name search of activity object:
>
> def name_search(self, cr, uid, name, args=None, operator='ilike',
> context=None, limit=80):
> if not args:
> args=[]
> acc_ids=[]
> if context.get('account_id',False):
>
> account_id
> =
> self
> .pool
> .get
> ('account
> .analytic.account').browse(cr,uid,context.get('account_id',False))
> #take the account wich have activity_ids
>
> acc_who_matters
> =self._get_first_AA_wich_have_activity(cr,uid,account_id)
> if acc_who_matters:
> for i in acc_who_matters.activity_ids:
> acc_ids.append(i.id)
> if not context:
> context={}
> account = self.search(cr, uid, [('code', '=', name),
> ('id','in',acc_ids)]+args, limit=limit, context=context)
> if not account:
> account = self.search(cr, uid, [('name', 'ilike', '%%%s%%' %
> name),('id','in',acc_ids)]+args, limit=limit, context=context)
> if not account:
> account = self.search(cr, uid, [('id','in',acc_ids)]+args,
> limit=limit, context=context)
> return self.name_get(cr, uid, account, context=context)

--

Joël Grand-Guillaume
OpenERP Consultant
Business Solutions

Camptocamp SA
PSE A, CH-1015 Lausanne
  www.camptocamp.com

Phone: +41 21 619 10 28
Office: +41 21 619 10 10
Fax: +41 21 619 10 00
Email: <email address hidden>

P Please consider the environment before printing this email