Skip to content

Commit

Permalink
Portal Email Readonly, pre-commit changes
Browse files Browse the repository at this point in the history
  • Loading branch information
kumarinie committed Sep 10, 2024
1 parent 4c426c9 commit a0bdf65
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 20 deletions.
11 changes: 8 additions & 3 deletions portal_email_readonly/__manifest__.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
{
"name": "portal_email_readonly",
"summary": """
This module is an addition to Odoo's portal module, and makes sure that the email field on the 'My Account' page in the portal / website / webshop is not editable by the portal user.
This can be very useful when making use of an extended authentication tooling that uses the email address as the user id, and you do not want this to be changed.
The module also introduces an error pop-up when a back office user is trying to change the email address field in any res.partner record after portal access has been granted to the res.user of the concerning res.partner.""",
This module is an addition to Odoo's portal module, and makes sure
that the email field on the 'My Account' page in the portal / website / webshop
is not editable by the portal user. This can be very useful when making use of an
extended authentication tooling that uses the email address as the user id,
and you do not want this to be changed. The module also introduces an error
pop-up when a back office user is trying to change the email address field in
any res.partner record after portal access has been granted to the res.user of
the concerning res.partner.""",
"author": "TOSC - K.Sushma, Odoo Community Association (OCA)",
"website": "https://github.com/OCA/website",
# Categories can be used to filter modules in modules listing
Expand Down
39 changes: 22 additions & 17 deletions portal_email_readonly/views/portal_templates.xml
Original file line number Diff line number Diff line change
@@ -1,25 +1,30 @@
<odoo>
<data>
<template id="portal_email_readonly" inherit_id="portal.portal_my_details">
<xpath expr="//div[contains(@t-attf-class, 'email')]" position="replace">
<t t-set="partner_can_edit_email" t-value="partner.can_edit_email()" />
<t

<xpath
expr="//div[contains(@t-attf-class, 'email')]/input[@name='email']"
position="attributes"
>
<attribute name="t-att-style">'display: none;'</attribute>
</xpath>
<xpath
expr="//div[contains(@t-attf-class, 'email')]/label[@for='email']"
position="after"
>
<t t-set="partner_can_edit_email" t-value="partner.can_edit_email()" />
<t
t-set="email_not_editable_message"
>You cannot change the email address. Please create a new contact person.</t>
<div
t-attf-class="form-group #{error.get('email') and 'o_has_error' or ''} col-xl-6"
>
<label class="col-form-label" for="email">Email</label>
<input
type="email"
name="email"
t-attf-class="form-control #{error.get('email') and 'is-invalid' or ''}"
t-att-value="email or partner.email"
t-att-readonly="None if partner_can_edit_email else '1'"
t-att-title="None if partner_can_edit_email else email_not_editable_message"
/>
</div>
</xpath>
<input
type="email"
name="email"
t-attf-class="form-control #{error.get('email') and 'is-invalid' or ''}"
t-att-value="email or partner.email"
t-att-readonly="None if partner_can_edit_email else '1'"
t-att-title="None if partner_can_edit_email else email_not_editable_message"
/>
</xpath>
</template>
</data>
</odoo>

0 comments on commit a0bdf65

Please sign in to comment.