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
|
|
@ -227,4 +227,52 @@ class TestMembershipSignup(TransactionCase):
|
|||
ctrl = WebsiteSaleMembershipSignup()
|
||||
billing_fields = ctrl._get_mandatory_billing_address_fields(country)
|
||||
self.assertNotIn("phone", billing_fields)
|
||||
self.assertIn("email", billing_fields)
|
||||
self.assertIn("email", billing_fields)
|
||||
|
||||
# -- Token-based signup: pre-fill firstname / lastname -----------------
|
||||
|
||||
def test_12_signup_retrieve_info_returns_firstname_lastname(self):
|
||||
"""When a partner is invited via token (the email-invitation flow),
|
||||
the core's `_signup_retrieve_info` only returns `name`. Our
|
||||
`res.partner` override adds `firstname` / `lastname` so the signup
|
||||
form (extended by this module to collect them separately) is
|
||||
pre-filled when the invited partner already has the split fields
|
||||
(which is the case with `partner_firstname` installed).
|
||||
|
||||
The invited partner must NOT have a user yet, otherwise the token
|
||||
payload check (`user_ids`) won't match.
|
||||
"""
|
||||
partner = self.env["res.partner"].create({
|
||||
"firstname": "Invited",
|
||||
"lastname": "Researcher",
|
||||
"email": "invited.researcher@example.com",
|
||||
"signup_type": "signup",
|
||||
})
|
||||
self.assertFalse(partner.user_ids, "test precondition: no user yet")
|
||||
token = partner._generate_signup_token()
|
||||
info = self.env["res.partner"]._signup_retrieve_info(token)
|
||||
self.assertEqual(info.get("firstname"), "Invited")
|
||||
self.assertEqual(info.get("lastname"), "Researcher")
|
||||
self.assertEqual(info.get("name"), partner.name)
|
||||
self.assertEqual(info.get("email"), "invited.researcher@example.com")
|
||||
|
||||
def test_13_signup_retrieve_info_legacy_partner_without_split(self):
|
||||
"""A partner created without `firstname`/`lastname` (legacy, only
|
||||
`name`) should not crash the override. `firstname`/`lastname` come
|
||||
back as '' (falsy), `name` as the legacy value, and the token flow
|
||||
still works — the form will show empty readonly inputs for the split
|
||||
fields, which is the best we can do without re-splitting.
|
||||
"""
|
||||
partner = self.env["res.partner"].create({
|
||||
"name": "Legacy Researcher",
|
||||
"email": "legacy@example.com",
|
||||
"signup_type": "signup",
|
||||
})
|
||||
# partner_firstname's post_create hook may or may not have split
|
||||
# `name` automatically; we just check the override does not crash
|
||||
# and returns the contract keys.
|
||||
token = partner._generate_signup_token()
|
||||
info = self.env["res.partner"]._signup_retrieve_info(token)
|
||||
self.assertIn("firstname", info)
|
||||
self.assertIn("lastname", info)
|
||||
self.assertEqual(info.get("name"), partner.name)
|
||||
Loading…
Add table
Add a link
Reference in a new issue