~openerp-dev/openobject-server/7.0-fix-contact-company-handling

Viewing all changes in revision 4939.

  • Committer: Olivier Dony
  • Date: 2013-04-19 13:57:56 UTC
  • Revision ID: odo@openerp.com-20130419135756-2kbhwr23lygqdoob
[FIX] res.partner: search using 'child_of' should include inactive children

This is necessary for 2 reasons:
- when searching on Business documents the search domain will be
  [('partner_id', 'child_of', 'ACME')] in order to match all
  descendants, and it must match inactive children as well
- in other cases like for resolving IDs to update via store
  triggers, it is necessary that 'child_of' returns inactive
  children too.

The implementation is tricky because the ORM automatically 
transform 'child_of' domains into recursive searches with
[('parent_id', 'in', ids)], which is the same query that the
reverse one2many 'child_ids' will also use to find contacts.
The overridden search() therefore matches this domain pattern
only when there is one criterion (to avoid side-effects in
other cases) and a dummy extra 'domain' was added to the
definition of the 'child_ids' o2m so it won't match.
The net result is that child_ids will not return inactive
children while child_of will return all descendants when
it is the only criterion. This is the expected behavior
whenever child_of is used on res.partner, because
it's safer to always show business documents.
The only side-effects will be for custom/manual search
calls with a single criterion of the form ('parent_id','in', x)
and those can be fixed by adding an extra domain
component ('active','=',True), just like child_ids does.

expand all expand all

Show diffs side-by-side

added added

removed removed

Lines of Context: