[FIX] website_hr_recruitment: remove useless csrf_token field

Steps to reproduce the bug:
- Go to /@/jobs/apply/experienced-developer-4
- Click on "Edit" button
- Click anywhere in the form
- Try to add a field
=> Nothing happens

Expected behavior:
You should be able to add a field without any problem.

Explanation of the bug:
A dynamic element is in the form (csrf_token) and it is preventing
the form to be modified correctly.
This was an artifact of a mistake made in commit [1].

Behavior after the fix:
You can add a field without any problem.

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

task-3593111

closes odoo/odoo#143456

Signed-off-by: Quentin Smetz (qsm) <qsm@odoo.com>
This commit is contained in:
Flotchet
2024-01-11 17:00:41 +00:00
committed by qsm-odoo
parent 128032a8b1
commit d7d40f5233
3 changed files with 14 additions and 4 deletions
@@ -5,7 +5,7 @@
'name': 'Online Jobs',
'category': 'Website/Website',
'sequence': 310,
'version': '1.0',
'version': '1.1',
'summary': 'Manage your online hiring process',
'description': "This module allows to publish your available job positions on your website and keep track of application submissions easily. It comes as an add-on of *Recruitment* app.",
'depends': ['hr_recruitment', 'website_mail'],
@@ -0,0 +1,13 @@
# Part of Odoo. See LICENSE file for full copyright and licensing details.
def migrate(cr, version):
# Remove the csrf_token and its surrounding div from the
# website_hr_recruitment.apply (it was set with a t-att- breaking the
# possibility to properly edit the form, and it was actually useless).
cr.execute(r"""
UPDATE ir_ui_view
SET arch_db = REGEXP_REPLACE(arch_db::text, '<div[^<]*>[^<]*<input[^>]+id=\\"csrf_token\\"[^>]*/>[^<]*</div>', '', 'g')::jsonb
WHERE key = 'website_hr_recruitment.apply'
AND website_id IS NOT NULL
AND arch_db::text LIKE '%csrf_token%'
""")
@@ -291,9 +291,6 @@
class="form-control s_website_form_input"
name="job_id"/>
</div>
<div class="col-sm">
<input id="csrf_token" type="hidden" name="csrf_token" t-att-value="request.csrf_token()"/>
</div>
</div>
</div>
<div class="col-12 mb-0 py-2 s_website_form_field s_website_form_dnone">