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.

23 lines
937 B

  1. # -*- encoding: utf-8 -*-
  2. ##############################################################################
  3. # For copyright and license notices, see __openerp__.py file in root directory
  4. ##############################################################################
  5. from openerp import models, fields
  6. class CrmLead(models.Model):
  7. _inherit = 'crm.lead'
  8. department = fields.Many2one(comodel_name='crm.department')
  9. def _lead_create_contact(self, cr, uid, lead, name, is_company,
  10. parent_id=False, context=None):
  11. """Propagate department to created partner.
  12. """
  13. partner_id = super(CrmLead, self)._lead_create_contact(
  14. cr, uid, lead, name, is_company, parent_id=parent_id,
  15. context=context)
  16. self.pool['res.partner'].write(
  17. cr, uid, partner_id, {'department': lead.department.id},
  18. context=context)
  19. return partner_id