You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

50 lines
2.1 KiB

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