[IMP] website_crm: allow creation of the lead to be overrided. That avoid people to rewrite all the routine of the form if they want to change the default behavior at lead creation when form is submitted.
This commit is contained in:
parent
6801a3f505
commit
a0ebd2c88e
|
@ -26,6 +26,10 @@ class contactus(http.Controller):
|
|||
values.update(kwargs=kwargs.items())
|
||||
return request.website.render("website.contactus", values)
|
||||
|
||||
def create_lead(self, request, values):
|
||||
""" Allow to be overrided """
|
||||
return request.registry['crm.lead'].create(request.cr, SUPERUSER_ID, values, request.context)
|
||||
|
||||
@http.route(['/crm/contactus'], type='http', auth="public", website=True, multilang=True)
|
||||
def contactus(self, **kwargs):
|
||||
def dict_to_str(title, dictvar):
|
||||
|
@ -42,12 +46,10 @@ class contactus(http.Controller):
|
|||
post_description = [] # Info to add after the message
|
||||
values = {'user_id': False}
|
||||
|
||||
lead_model = request.registry['crm.lead']
|
||||
|
||||
for field_name, field_value in kwargs.items():
|
||||
if hasattr(field_value, 'filename'):
|
||||
post_file.append(field_value)
|
||||
elif field_name in lead_model._all_columns and field_name not in _BLACKLIST:
|
||||
elif field_name in request.registry['crm.lead']._all_columns and field_name not in _BLACKLIST:
|
||||
values[field_name] = field_value
|
||||
elif field_name not in _TECHNICAL: # allow to add some free fields or blacklisted field like ID
|
||||
post_description.append("%s: %s" % (field_name, field_value))
|
||||
|
@ -81,7 +83,7 @@ class contactus(http.Controller):
|
|||
post_description.append("%s: %s" % ("REFERER", environ.get("HTTP_REFERER")))
|
||||
values['description'] += dict_to_str(_("Environ Fields: "), post_description)
|
||||
|
||||
lead_id = lead_model.create(request.cr, SUPERUSER_ID, values, request.context)
|
||||
lead_id = self.create_lead(request, values)
|
||||
if lead_id:
|
||||
for field_value in post_file:
|
||||
attachment_value = {
|
||||
|
|
Loading…
Reference in New Issue