[ADD] project_name_from_lead

This commit is contained in:
clementthomas
2023-03-27 17:22:38 +02:00
parent 139e451d0c
commit 355e77fc70
7 changed files with 127 additions and 0 deletions

View File

@@ -0,0 +1,17 @@
from odoo import models
class Lead(models.Model):
_inherit = 'crm.lead'
def write(self, vals):
"""update project name if project created from lead
"""
for lead in self:
if 'name' in vals:
sale = self.env['sale.order'].search([('opportunity_id','=',lead.id)])
if sale:
project = self.env['project.project'].search([('sale_order_id','=',sale.id)])
if project:
project.name = vals['name']
return super(Lead, self).write(vals)