[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 42af65d4d1
9 changed files with 900 additions and 0 deletions

View File

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

View File

@@ -0,0 +1,53 @@
# Copyright 2026 Elabore
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from odoo import api, models
class ResUsers(models.Model):
"""
Bridge passwordless signup with split first and last names.
"""
_inherit = "res.users"
@api.model
def _get_signup_name(self, values):
"""
Build a name from the split signup name fields.
:param dict values: signup values containing optional ``firstname``
and ``lastname`` entries.
:return: the joined non-empty name parts, or ``False`` when both
parts are empty.
"""
parts = [
part.strip()
for part in (values.get("firstname"), values.get("lastname"))
if part and part.strip()
]
return " ".join(parts) or False
@api.model
def _signup_create_user(self, values):
"""
Fill ``name`` before the core signup guard runs.
``auth_signup_verify_email`` sends the raw signup request values to
``res.users.signup()`` without preparing them through the signup
controller. When the form posts ``firstname``/``lastname`` instead
of ``name`` (as ``partner_firstname`` forms do), the core
``_create_user_from_template()`` guard rejects the request. Derive
``name`` here so the guard passes; ``partner_firstname`` still
computes the final partner name from the split fields.
:param dict values: signup values forwarded by ``res.users.signup``.
:return: the created user record.
:raises ValueError: propagated from the core guard when no name can
be derived and no partner is provided.
"""
if not values.get("name") and not values.get("partner_id"):
name = self._get_signup_name(values)
if name:
values["name"] = name
return super()._signup_create_user(values)