generated from OCA/oca-addons-repo-template
-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[WIP] T0485 [MIG] website_compassion: rewrite registration process
- Use Odoo traditional signup process but inject partner search capability given a reference (child or sponsor)
- Loading branch information
Showing
12 changed files
with
73 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
############################################################################## | ||
# | ||
# Copyright (C) 2023 Compassion CH (http://www.compassion.ch) | ||
# @author: Emanuel Cino <ecino@compassion.ch> | ||
# | ||
# The licence is in the file __manifest__.py | ||
# | ||
############################################################################## | ||
|
||
from odoo import _ | ||
from odoo.http import request | ||
from odoo.addons.auth_signup.controllers.main import AuthSignupHome | ||
|
||
|
||
class RegistrationController(AuthSignupHome): | ||
def do_signup(self, qcontext): | ||
""" | ||
Check if a sponsor ref was given in order to try to match | ||
an existing sponsor. | ||
""" | ||
sponsor_ref = qcontext.get("sponsor_ref") | ||
if sponsor_ref: | ||
sponsor = request.env["res.partner"].sudo().search( | ||
[("ref", "=", sponsor_ref)], limit=1 | ||
) | ||
if not sponsor: | ||
# Try to find based on a child reference, either global or local | ||
child = request.env["compassion.child"].sudo().search( | ||
[ | ||
("state", "=", "P"), | ||
"|", | ||
("global_id", "=", sponsor_ref), | ||
("local_id", "=", sponsor_ref), | ||
], limit=1 | ||
) | ||
sponsor = child.sponsor_id | ||
if sponsor: | ||
if sponsor.email.lower() != qcontext["login"].lower(): | ||
qcontext["error"] = _( | ||
"The email address you entered is not the same " | ||
"as the one in the system. Please try again." | ||
) | ||
return super().do_signup(qcontext) | ||
# Prepare token for signup | ||
sponsor.signup_prepare() | ||
qcontext["token"] = sponsor.signup_token | ||
else: | ||
qcontext["error"] = _("No sponsor found with this reference") | ||
return super().do_signup(qcontext) |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<odoo> | ||
|
||
<template id="signup_sponsor" inherit_id="auth_signup.fields"> | ||
<xpath expr="//div[@class='form-group field-name']" position="after"> | ||
<div class="form-group field-name"> | ||
<label for="sponsor_ref">Your sponsor or child reference</label> | ||
<input t-att-type="'hidden' if only_passwords else 'text'" name="sponsor_ref" id="sponsor_ref" class="form-control form-control-sm" placeholder="Put any known reference here for matching with your account..."/> | ||
</div> | ||
</xpath> | ||
</template> | ||
|
||
</odoo> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters