32 lines
No EOL
1.4 KiB
Python
32 lines
No EOL
1.4 KiB
Python
# 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 |