[ADD] auth_signup_verify_email_partner_firstname: derive signup name

``auth_signup_verify_email`` forwards the raw signup values to
``res.users.signup()``. When the form posts ``firstname``/``lastname``
instead of ``name`` (as ``partner_firstname`` forms do), the core
``_create_user_from_template()`` guard rejects the request.

This glue module is auto-installed when both modules are installed and
derives ``name`` before the guard runs. ``partner_firstname`` keeps
computing the final partner name from the split fields.
This commit is contained in:
Stéphan Sainléger
2026-11-06 14:08:00 +01:00
parent e6d43f6917
commit b5ce245858
9 changed files with 900 additions and 0 deletions

View File

@@ -0,0 +1 @@
from . import test_signup

View File

@@ -0,0 +1,97 @@
# Copyright 2026 Elabore
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from unittest.mock import patch
from odoo import http
from odoo.tests import HttpCase, TransactionCase, tagged
from odoo.addons.mail.models import mail_template
@tagged("post_install", "-at_install")
class TestSignupName(TransactionCase):
"""
Test the name derivation at the res.users signup boundary.
"""
def setUp(self):
"""
Enable free signup for the test cases.
"""
super().setUp()
if "website" in self.env:
self.env["website"].get_current_website().auth_signup_uninvited = "b2c"
self.env["ir.config_parameter"].sudo().set_param(
"auth_signup.invitation_scope", "b2c"
)
def test_signup_create_user_from_split_name(self):
"""
Create a user from firstname/lastname without an explicit name.
"""
user = self.env["res.users"]._signup_create_user(
{
"login": "split.name@example.com",
"email": "split.name@example.com",
"firstname": "Jean",
"lastname": "Dupont",
"password": "",
}
)
self.assertEqual(user.firstname, "Jean")
self.assertEqual(user.lastname, "Dupont")
self.assertTrue(user.name)
def test_signup_create_user_without_name_still_fails(self):
"""
Keep the core guard when no name information is available.
"""
with self.assertRaises(ValueError):
self.env["res.users"]._signup_create_user(
{
"login": "nameless@example.com",
"email": "nameless@example.com",
"password": "",
}
)
@tagged("post_install", "-at_install")
class TestPasswordlessSignup(HttpCase):
"""
Test the full auth_signup_verify_email passwordless flow.
"""
def setUp(self):
"""
Enable free signup on the website and in the signup settings.
"""
super().setUp()
if "website" in self.env:
self.env["website"].get_current_website().auth_signup_uninvited = "b2c"
self.env["ir.config_parameter"].sudo().set_param(
"auth_signup.invitation_scope", "b2c"
)
def test_passwordless_signup_with_split_name(self):
"""
Create a user from the passwordless form with split names.
"""
self.authenticate(None, None)
payload = {
"csrf_token": http.Request.csrf_token(self),
"login": "contributors@odoo-community.org",
"firstname": "Jean",
"lastname": "Dupont",
}
with patch.object(mail_template.MailTemplate, "send_mail"):
self.url_open("/web/signup", data=payload)
user = (
self.env["res.users"]
.sudo()
.search([("login", "=", "contributors@odoo-community.org")])
)
self.assertTrue(user)
self.assertEqual(user.firstname, "Jean")
self.assertEqual(user.lastname, "Dupont")