~openerp-commiter/openobject-addons/extra-6.0

« back to all changes in this revision

Viewing changes to partner_address_ldap/partner.py

  • Committer: Joël Grand-Guillaume
  • Date: 2011-08-12 13:09:53 UTC
  • Revision ID: joel.grandguillaume@camptocamp.com-20110812130953-qenr7wh362ip7xqx
[DEL] Move all C2C modules to the c2c-addons official branch (bzr branch lp:c2c-addons)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# -*- coding: utf-8 -*-
2
 
##############################################################################
3
 
#
4
 
# Copyright (c) 2010 Camptocamp SA (http://www.camptocamp.com) 
5
 
# All Right Reserved
6
 
#
7
 
# Author : Nicolas Bessi (Camptocamp), Thanks to Laurent Lauden for his code adaptation
8
 
# Active directory Donor: M. Benadiba (Informatique Assistances.fr)
9
 
# Contribution : Joel Grand-Guillaume
10
 
#
11
 
# WARNING: This program as such is intended to be used by professional
12
 
# programmers who take the whole responsability of assessing all potential
13
 
# consequences resulting from its eventual inadequacies and bugs
14
 
# End users who are looking for a ready-to-use solution with commercial
15
 
# garantees and support are strongly adviced to contract a Free Software
16
 
# Service Company
17
 
#
18
 
# This program is Free Software; you can redistribute it and/or
19
 
# modify it under the terms of the GNU General Public License
20
 
# as published by the Free Software Foundation; either version 2
21
 
# of the License, or (at your option) any later version.
22
 
#
23
 
# This program is distributed in the hope that it will be useful,
24
 
# but WITHOUT ANY WARRANTY; without even the implied warranty of
25
 
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
26
 
# GNU General Public License for more details.
27
 
#
28
 
# You should have received a copy of the GNU General Public License
29
 
# along with this program; if not, write to the Free Software
30
 
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
31
 
#
32
 
##############################################################################
33
 
 
34
 
from osv import osv, fields
35
 
        
36
 
class LdapPartner(osv.osv):
37
 
    """Ensure that when deleting a partner unlink function is called on all
38
 
    related addresses"""
39
 
    _inherit = 'res.partner'
40
 
    
41
 
    def unlink(self, cursor, uid, ids, context=None):
42
 
        context = context or {}
43
 
        addr_obj = self.pool.get('res.partner.address')
44
 
        if not isinstance(ids, list):
45
 
            ids = [ids]
46
 
        addr_ids = addr_obj.search(cursor, uid, [('partner_id', 'in', ids)])
47
 
        addr_obj.unlink(cursor, uid, addr_ids, context=context)
48
 
        return super(LdapPartner, self).unlink(cursor, uid, ids, context=context)
49
 
 
50
 
LdapPartner()