Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

17.0 website event signup fix 2024 12 12 #15

Draft
wants to merge 4 commits into
base: 17.0
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 21 additions & 13 deletions website_event_attendee_signup/data/mail_template_data.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,34 +2,42 @@
<odoo noupdate="1">
<record id="email_template_signup" model="mail.template">
<field name="name">Event: Signup</field>
<!--<field name="email_from">${(object.partner_id.email or '')|safe}</field>-->
<field
name="email_from"
>{{ (object.event_id.organizer_id.email_formatted or object.event_id.user_id.email_formatted or '') }}</field>
<field name="subject">Welcome to our Portal!</field>
<field name="partner_to">${object.attendee_partner_id.id}</field>
<field
name="email_to"
>{{object.attendee_partner_id.email or object.partner_id.email}}</field>
<field name="model_id" ref="event.model_event_registration" />
<field name="auto_delete" eval="True" />
<field name="lang">${object.attendee_partner_id.lang}</field>
<field
name="body_html"
><![CDATA[

name="lang"
>{{object.attendee_partner_id.lang or object.event_id.lang or object.partner_id.lang}}</field>
<field name="body_html" type="html">
<p>
Hello ${object.attendee_partner_id.name},<br />
Hello <t t-out="object.attendee_partner_id.name" />,<br />

You was registered as attendee of ${object.event_id.name}.
You was registered as attendee of <t t-out="object.event_id.name" />.

% if object.attendee_partner_id.signup_token:
<t t-if="object.attendee_partner_id.signup_token">
Use the link below to sing-up on portal to access your event dashboard:
<div style="padding:0px;width:600px;margin:auto;background: #FFFFFF repeat top /100%;color:#777777">
<div
style="padding:0px;width:600px;margin:auto;background: #FFFFFF repeat top /100%;color:#777777"
>
<div style="text-align: center; margin-top: 16px;">
<a href="${object.attendee_partner_id.signup_url}" style="padding: 5px 10px; font-size: 12px; line-height: 18px; color: #FFFFFF; border-color:#875A7B; text-decoration: none; display: inline-block; margin-bottom: 0px; font-weight: 400; text-align: center; vertical-align: middle; cursor: pointer; white-space: nowrap; background-image: none; background-color: #875A7B; border: 1px solid #875A7B; border-radius:3px">Accept invitation to portal</a>
<a
t-att-href="object.attendee_partner_id.signup_url"
style="padding: 5px 10px; font-size: 12px; line-height: 18px; color: #FFFFFF; border-color:#875A7B; text-decoration: none; display: inline-block; margin-bottom: 0px; font-weight: 400; text-align: center; vertical-align: middle; cursor: pointer; white-space: nowrap; background-image: none; background-color: #875A7B; border: 1px solid #875A7B; border-radius:3px"
>Accept invitation to portal</a>
</div>
</div>
% endif
</t>
</p>
<p>
</p>
<p>Best regards,</p>

]]></field>
</field>
</record>
</odoo>
55 changes: 36 additions & 19 deletions website_event_attendee_signup/models/event_registration.py
Original file line number Diff line number Diff line change
@@ -1,24 +1,41 @@
from odoo import api, models
from odoo import models


class EventRegistration(models.Model):
_inherit = "event.registration"

@api.model
def create(self, vals):
res = super().create(vals)

if res.event_id.attendee_signup and res.attendee_partner_id:
login = res.attendee_partner_id.email
user = self.env["res.users"].search([("login", "=ilike", login)])
if not user:
user = (
self.env["res.users"]
.sudo()
._signup_create_user(
{"login": login, "partner_id": res.attendee_partner_id.id}
)
)
user.partner_id.signup_prepare()

return res
def _update_attendee_partner_id(self, vals):
vals = super()._update_attendee_partner_id(vals)
if not vals.get("attendee_partner_id"):
return vals

if not vals.get("event_id"):
return vals

Partner = self.env["res.partner"].sudo()
Users = self.env["res.users"].sudo()
Events = self.env["event.event"].sudo()

event = Events.browse(vals["event_id"])
if not event.attendee_signup:
return vals

attendee_partner = Partner.browse(vals["attendee_partner_id"])
if attendee_partner.user_ids:
# already has user
return vals

login = attendee_partner.email
if not login:
return vals

user = Users.search([("login", "=ilike", login)])
if user:
# already has user with given address
return vals

user = Users._signup_create_user(
{"login": login, "partner_id": attendee_partner.id}
)
user.partner_id.signup_prepare()
return vals
Loading