website_membership_signup_required: fix token signup name fields
This commit is contained in:
parent
ba52c72b78
commit
c439607ce1
3 changed files with 82 additions and 1 deletions
|
|
@ -2,4 +2,5 @@
|
|||
|
||||
from . import website
|
||||
from . import res_config_settings
|
||||
from . import res_partner
|
||||
from . import res_users
|
||||
32
website_membership_signup_required/models/res_partner.py
Normal file
32
website_membership_signup_required/models/res_partner.py
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||
|
||||
from odoo import api, models
|
||||
|
||||
|
||||
class ResPartner(models.Model):
|
||||
_inherit = "res.partner"
|
||||
|
||||
@api.model
|
||||
def _signup_retrieve_info(self, token):
|
||||
"""Extend the core's token-based signup info with `firstname` and
|
||||
`lastname` so the signup form (extended by this module to collect
|
||||
them separately via `partner_firstname`) can be pre-filled and
|
||||
shown readonly when the visitor follows an invitation link.
|
||||
|
||||
The core (`auth_signup/models/res_partner.py:_signup_retrieve_info`)
|
||||
only returns `name`, `login` and `email`. Our signup template
|
||||
replaced the single `name` input with `firstname` / `lastname`
|
||||
inputs, so without this override those inputs would be empty (and
|
||||
readonly, because `only_passwords` is True for token flows) when
|
||||
an invited partner already has the split fields populated.
|
||||
|
||||
We keep `name` in the returned dict (the core's contract) and add
|
||||
the two split fields so the controller's `setdefault` populates
|
||||
the qcontext transparently.
|
||||
"""
|
||||
res = super()._signup_retrieve_info(token)
|
||||
partner = self._get_partner_from_token(token)
|
||||
if partner:
|
||||
res["firstname"] = partner.firstname or ""
|
||||
res["lastname"] = partner.lastname or ""
|
||||
return res
|
||||
Loading…
Add table
Add a link
Reference in a new issue