[FIX] website, website_form_project: set email_from as custom for task

Commit [1] removed the `email_from` field from the `project.task` model
but forgot to adapt/delete some field occurences.

One of those is related to the form in the website builder which allows
to create task when the form is sent.

Two errors were detected:

- Non critical:

  The field is still passed to the form field whitelisting process.
  Since the whitelisting is done in raw SQL, it didn't crash or log
  anything even if the column did not exist anymore.

- Critical:

  The field was still marked as model required in the form JS registry,
  altering the form builder behaviors.
  One of those is that when the form input related to this field was
  re-created (eg when changing / hovering an option in the right panel),
  it would lose it's "name" attribute.
  Two possible issues from that point:
  1. When a visitor submit the form, the "email_from" field value is not
     set anymore in the task description and that information is just
     lost. You then have no way to reach back to him.
  2. (Minor) The auto-fill behavior of the form was not working anymore

Probably more issues were introduced but only those ones got detected as
of today.

Step to reproduce:
- Drop a website form, choose "Create a Task"
- Focus the default "Email" field
- Hover the mouse on the "eye" icon ("Invisible") next to the Position
  attribute. If you inspect the DOM, the input has now lost the `name`
  attribute.
- If you save, you will face the issues reported above.
- If you then reopen the editor and focus the email field again, the
  tooltip will now say that the "null" field is required.

[1]: https://github.com/odoo/odoo/commit/a424cf481c676a230beeb6102fc67bedf472a882

opw-3626573

closes odoo/odoo#146170

X-original-commit: 6679fddbcaf7d9146ab242e0eed61ee0628f047f
Signed-off-by: Quentin Smetz (qsm) <qsm@odoo.com>
Signed-off-by: Romain Derie (rde) <rde@odoo.com>
This commit is contained in:
Romain Derie
2023-12-13 17:12:01 +00:00
parent 170f09c118
commit dede76bd5c
3 changed files with 11 additions and 2 deletions
+9
View File
@@ -1,9 +1,13 @@
# -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.
import logging
from odoo import models, fields, api, SUPERUSER_ID
from odoo.http import request
_logger = logging.getLogger(__name__)
class website_form_config(models.Model):
_inherit = 'website'
@@ -116,6 +120,11 @@ class website_form_model_fields(models.Model):
if not self.env['res.users'].has_group('website.group_website_designer'):
return False
unexisting_fields = [field for field in fields if field not in self.env[model]._fields.keys()]
if unexisting_fields:
# TODO in master: Raise instead of log
_logger.error("Unable to whitelist field(s) %r for model %r.", unexisting_fields, model)
# the ORM only allows writing on custom fields and will trigger a
# registry reload once that's happened. We want to be able to
# whitelist non-custom fields and the registry reload absolutely
@@ -11,7 +11,6 @@
<value>project.task</value>
<value eval="[
'name',
'email_from',
'description',
'project_id',
]"/>
@@ -11,7 +11,8 @@ FormEditorRegistry.add('create_task', {
string: _t('Task Title'),
}, {
type: 'email',
modelRequired: true,
custom: true,
required: true,
fillWith: 'email',
name: 'email_from',
string: _t('Your Email'),