Skip to content
Snippets Groups Projects
Commit d22d4dcc authored by Lucas Perais (lpe)'s avatar Lucas Perais (lpe)
Browse files

[FIX] website_crm: fix lead creation through website_form

Before this commit, a message received through the contact us form did create a Lead, but any notification was impossible (even if a user was a follower of the relevant sales team.
This was because the default sales team is integrated in the values for create in models.py, which mail_thread can't see, but needs in order to notify

This commit corrects the behavior which now converge with standard lead creation by adding the default sales_team earlier in the values for create

OPW 762651

closes #19180
parent 11ce4d22
No related branches found
No related tags found
No related merge requests found
from openerp import models, SUPERUSER_ID
from openerp import models
class Lead(models.Model):
_inherit = 'crm.lead'
def website_form_input_filter(self, request, values):
defaults = self.default_get(['medium_id', 'team_id'])
values['medium_id'] = (
values.get('medium_id') or
self.default_get(['medium_id']).get('medium_id') or
defaults.get('medium_id') or
self.sudo().env['ir.model.data'].xmlid_to_res_id('utm.utm_medium_website')
)
values['team_id'] = values.get('team_id') or defaults.get('team_id')
if not values['team_id']:
team_model = self.env['ir.model'].search([('model', '=', 'crm.team')])
lead_model = self.env['ir.model'].search([('model', '=', 'crm.lead')])
values['team_id'] = self.env['mail.alias'].search([('alias_model_id', '=', lead_model.id),
('alias_parent_model_id', '=', team_model.id),
('alias_name', 'ilike', '%\web%')], limit=1).alias_parent_thread_id
return values
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment