|
@ -19,10 +19,10 @@ |
|
|
# |
|
|
# |
|
|
############################################################################## |
|
|
############################################################################## |
|
|
|
|
|
|
|
|
from openerp.osv import fields, osv, expression |
|
|
|
|
|
|
|
|
from openerp.osv import fields, orm, expression |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class res_partner(osv.osv): |
|
|
|
|
|
|
|
|
class res_partner(orm.Model): |
|
|
_inherit = 'res.partner' |
|
|
_inherit = 'res.partner' |
|
|
|
|
|
|
|
|
_contact_type = [ |
|
|
_contact_type = [ |
|
@ -45,7 +45,8 @@ class res_partner(osv.osv): |
|
|
'other_contact_ids': fields.one2many('res.partner', 'contact_id', 'Others Positions'), |
|
|
'other_contact_ids': fields.one2many('res.partner', 'contact_id', 'Others Positions'), |
|
|
|
|
|
|
|
|
# Person specific fields |
|
|
# Person specific fields |
|
|
'birthdate_date': fields.date('Birthdate'), # add a 'birthdate' as date field, i.e different from char 'birthdate' introduced v6.1! |
|
|
|
|
|
|
|
|
# add a 'birthdate' as date field, i.e different from char 'birthdate' introduced v6.1! |
|
|
|
|
|
'birthdate_date': fields.date('Birthdate'), |
|
|
'nationality_id': fields.many2one('res.country', 'Nationality'), |
|
|
'nationality_id': fields.many2one('res.country', 'Nationality'), |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
@ -54,22 +55,22 @@ class res_partner(osv.osv): |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
def _basecontact_check_context(self, cr, user, mode, context=None): |
|
|
def _basecontact_check_context(self, cr, user, mode, context=None): |
|
|
|
|
|
""" Remove 'search_show_all_positions' for non-search mode. |
|
|
|
|
|
Keeping it in context can result in unexpected behaviour (ex: reading |
|
|
|
|
|
one2many might return wrong result - i.e with "attached contact" removed |
|
|
|
|
|
even if it's directly linked to a company). """ |
|
|
if context is None: |
|
|
if context is None: |
|
|
context = {} |
|
|
context = {} |
|
|
# Remove 'search_show_all_positions' for non-search mode. |
|
|
|
|
|
# Keeping it in context can result in unexpected behaviour (ex: reading |
|
|
|
|
|
# one2many might return wrong result - i.e with "attached contact" removed |
|
|
|
|
|
# even if it's directly linked to a company). |
|
|
|
|
|
if mode != 'search': |
|
|
if mode != 'search': |
|
|
context.pop('search_show_all_positions', None) |
|
|
context.pop('search_show_all_positions', None) |
|
|
return context |
|
|
return context |
|
|
|
|
|
|
|
|
def search(self, cr, user, args, offset=0, limit=None, order=None, context=None, count=False): |
|
|
def search(self, cr, user, args, offset=0, limit=None, order=None, context=None, count=False): |
|
|
|
|
|
""" Display only standalone contact matching ``args`` or having |
|
|
|
|
|
attached contact matching ``args`` """ |
|
|
if context is None: |
|
|
if context is None: |
|
|
context = {} |
|
|
context = {} |
|
|
if context.get('search_show_all_positions') is False: |
|
|
if context.get('search_show_all_positions') is False: |
|
|
# display only standalone contact matching ``args`` or having |
|
|
|
|
|
# attached contact matching ``args`` |
|
|
|
|
|
args = expression.normalize_domain(args) |
|
|
args = expression.normalize_domain(args) |
|
|
attached_contact_args = expression.AND((args, [('contact_type', '=', 'attached')])) |
|
|
attached_contact_args = expression.AND((args, [('contact_type', '=', 'attached')])) |
|
|
attached_contact_ids = super(res_partner, self).search(cr, user, attached_contact_args, |
|
|
attached_contact_ids = super(res_partner, self).search(cr, user, attached_contact_args, |
|
@ -163,7 +164,7 @@ class res_partner(osv.osv): |
|
|
return {'value': values} |
|
|
return {'value': values} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class ir_actions_window(osv.osv): |
|
|
|
|
|
|
|
|
class ir_actions_window(orm.Model): |
|
|
_inherit = 'ir.actions.act_window' |
|
|
_inherit = 'ir.actions.act_window' |
|
|
|
|
|
|
|
|
def read(self, cr, user, ids, fields=None, context=None, load='_classic_read'): |
|
|
def read(self, cr, user, ids, fields=None, context=None, load='_classic_read'): |
|
|