577 lines
38 KiB
XML
577 lines
38 KiB
XML
<?xml version="1.0" encoding="utf-8"?>
|
|
<odoo>
|
|
<!-- Template for the contact list -->
|
|
<template id="portal_my_contacts" name="My Contacts">
|
|
<t t-call="portal.portal_layout">
|
|
<div class="o_portal_my_home">
|
|
<div class="oe_structure" />
|
|
|
|
<!-- Page title -->
|
|
<div class="o_portal_my_details">
|
|
<h3 class="page-header">
|
|
My Contacts
|
|
</h3>
|
|
|
|
<!-- Success messages -->
|
|
<t t-if="request.params.get('create') == 'success'">
|
|
<div class="alert alert-success alert-dismissible fade show" role="alert">
|
|
<i class="fa fa-check mr-2"></i> The contact has been successfully created.
|
|
<button type="button" class="close" data-dismiss="alert" aria-label="Close">
|
|
<span aria-hidden="true">&times;</span>
|
|
</button>
|
|
</div>
|
|
</t>
|
|
<t t-if="request.params.get('update') == 'success'">
|
|
<div class="alert alert-success alert-dismissible fade show" role="alert">
|
|
<i class="fa fa-check mr-2"></i> The contact has been successfully updated.
|
|
<button type="button" class="close" data-dismiss="alert" aria-label="Close">
|
|
<span aria-hidden="true">&times;</span>
|
|
</button>
|
|
</div>
|
|
</t>
|
|
<t t-if="request.params.get('access_granted') == 'success'">
|
|
<div class="alert alert-success alert-dismissible fade show" role="alert">
|
|
<i class="fa fa-check mr-2"></i> Portal access has been granted to the contact. An invitation email has been sent.
|
|
<button type="button" class="close" data-dismiss="alert" aria-label="Close">
|
|
<span aria-hidden="true">&times;</span>
|
|
</button>
|
|
</div>
|
|
</t>
|
|
<t t-if="request.params.get('password_set') == 'success'">
|
|
<div class="alert alert-success alert-dismissible fade show" role="alert">
|
|
<i class="fa fa-check mr-2"></i> The password has been set successfully for the contact.
|
|
<button type="button" class="close" data-dismiss="alert" aria-label="Close">
|
|
<span aria-hidden="true">&times;</span>
|
|
</button>
|
|
</div>
|
|
</t>
|
|
<t t-if="request.params.get('archive') == 'success' or request.params.get('status_change') == 'archived'">
|
|
<div class="alert alert-success alert-dismissible fade show" role="alert">
|
|
<i class="fa fa-check mr-2"></i> The contact has been archived successfully.
|
|
<button type="button" class="close" data-dismiss="alert" aria-label="Close">
|
|
<span aria-hidden="true">&times;</span>
|
|
</button>
|
|
</div>
|
|
</t>
|
|
|
|
<t t-if="request.params.get('status_change') == 'portal_granted'">
|
|
<div class="alert alert-success alert-dismissible fade show" role="alert">
|
|
<i class="fa fa-check mr-2"></i> Portal access has been granted to the contact.
|
|
<button type="button" class="close" data-dismiss="alert" aria-label="Close">
|
|
<span aria-hidden="true">&times;</span>
|
|
</button>
|
|
</div>
|
|
</t>
|
|
|
|
<t t-if="request.params.get('status_change') == 'access_removed'">
|
|
<div class="alert alert-success alert-dismissible fade show" role="alert">
|
|
<i class="fa fa-check mr-2"></i> Portal access has been removed and the contact has been unarchived.
|
|
<button type="button" class="close" data-dismiss="alert" aria-label="Close">
|
|
<span aria-hidden="true">&times;</span>
|
|
</button>
|
|
</div>
|
|
</t>
|
|
|
|
<t t-if="request.params.get('success') == 'invitation_sent'">
|
|
<div class="alert alert-success alert-dismissible fade show" role="alert">
|
|
<i class="fa fa-check-circle mr-2"></i> Invitation email successfully sent.
|
|
<button type="button" class="close" data-dismiss="alert" aria-label="Close">
|
|
<span aria-hidden="true">&times;</span>
|
|
</button>
|
|
</div>
|
|
</t>
|
|
|
|
<!-- Error messages -->
|
|
<t t-if="request.params.get('error') == 'email_required'">
|
|
<div class="alert alert-danger alert-dismissible fade show" role="alert">
|
|
<i class="fa fa-exclamation-triangle mr-2"></i> An email address is required to grant portal access.
|
|
<button type="button" class="close" data-dismiss="alert" aria-label="Close">
|
|
<span aria-hidden="true">&times;</span>
|
|
</button>
|
|
</div>
|
|
</t>
|
|
<t t-if="request.params.get('error') == 'user_exists'">
|
|
<div class="alert alert-danger alert-dismissible fade show" role="alert">
|
|
<i class="fa fa-exclamation-triangle mr-2"></i> A user with this email already exists.
|
|
<button type="button" class="close" data-dismiss="alert" aria-label="Close">
|
|
<span aria-hidden="true">&times;</span>
|
|
</button>
|
|
</div>
|
|
</t>
|
|
<t t-if="request.params.get('error') == 'grant_access'">
|
|
<div class="alert alert-danger alert-dismissible fade show" role="alert">
|
|
<i class="fa fa-exclamation-triangle mr-2"></i> An error occurred while granting portal access.
|
|
<button type="button" class="close" data-dismiss="alert" aria-label="Close">
|
|
<span aria-hidden="true">&times;</span>
|
|
</button>
|
|
</div>
|
|
</t>
|
|
<t t-if="request.params.get('error') == 'archive' or request.params.get('error') == 'status_change'">
|
|
<div class="alert alert-danger alert-dismissible fade show" role="alert">
|
|
<i class="fa fa-exclamation-triangle mr-2"></i> An error occurred while updating the contact status.
|
|
<button type="button" class="close" data-dismiss="alert" aria-label="Close">
|
|
<span aria-hidden="true">&times;</span>
|
|
</button>
|
|
</div>
|
|
</t>
|
|
|
|
<!-- Special alert for contacts with active users -->
|
|
<t t-if="request.params.get('error') == 'has_users'">
|
|
<div class="alert alert-warning alert-dismissible fade show" role="alert">
|
|
<h5><i class="fa fa-exclamation-triangle mr-2"></i> Cannot archive contact with active users</h5>
|
|
<p>
|
|
The contact has active portal users associated with it: <strong t-esc="request.params.get('user_list')"></strong>
|
|
</p>
|
|
<p>
|
|
You need to archive both the contact and its associated users.
|
|
</p>
|
|
<div class="mt-3">
|
|
<a t-att-href="request.params.get('archive_url')" class="btn btn-primary">
|
|
<i class="fa fa-archive mr-1"></i> Archive Contact and Portal Users
|
|
</a>
|
|
</div>
|
|
<button type="button" class="close" data-dismiss="alert" aria-label="Close">
|
|
<span aria-hidden="true">&times;</span>
|
|
</button>
|
|
</div>
|
|
</t>
|
|
|
|
<!-- Bouton d'ajout de contact -->
|
|
<t t-if="can_add_contact">
|
|
<div class="mb-4">
|
|
<a href="/my/contacts/add" class="btn btn-primary">
|
|
<i class="fa fa-plus mr-1"></i> Add a contact
|
|
</a>
|
|
</div>
|
|
</t>
|
|
|
|
<!-- Liste des contacts -->
|
|
<t t-if="contacts">
|
|
<div class="o_portal_contact_list">
|
|
<div class="row">
|
|
<!-- Boucle sur les contacts -->
|
|
<t t-foreach="contacts" t-as="contact">
|
|
<!-- Conteneur pour chaque contact -->
|
|
<div class="col-lg-4 col-md-6 mb-4" t-att-data-contact-id="contact.id">
|
|
<div class="card h-100" t-att-class="'text-muted' if not contact.active else ''">
|
|
<div class="card-header" t-att-class="'bg-danger text-white' if not contact.active else 'bg-primary text-white'">
|
|
<h5 class="mb-0">
|
|
<i class="fa fa-user mr-2"></i> <t t-esc="contact.name"/>
|
|
</h5>
|
|
</div>
|
|
<div class="card-body d-flex flex-column">
|
|
<div class="mb-3">
|
|
<strong>Email:</strong> <span t-field="contact.email"/>
|
|
</div>
|
|
<div class="mb-3">
|
|
<strong>Phone:</strong> <span t-field="contact.phone"/>
|
|
</div>
|
|
<div class="mb-3">
|
|
<strong>Mobile:</strong> <span t-field="contact.mobile"/>
|
|
</div>
|
|
<div class="mb-3">
|
|
<strong>Status:</strong>
|
|
<span t-if="contact.user_ids and contact.active" class="badge badge-success">
|
|
<i class="fa fa-check mr-1"></i> Portal Access
|
|
</span>
|
|
<span t-if="not contact.user_ids and contact.active" class="badge badge-secondary">
|
|
<i class="fa fa-user-o mr-1"></i> No Access
|
|
</span>
|
|
<span t-if="not contact.active" class="badge badge-danger">
|
|
<i class="fa fa-archive mr-1"></i> Archived
|
|
</span>
|
|
</div>
|
|
<div class="mt-auto">
|
|
<div class="d-flex justify-content-center">
|
|
<div class="btn-group">
|
|
<button type="button" class="btn btn-outline-secondary dropdown-toggle" data-toggle="dropdown" aria-expanded="false" data-display="static" data-boundary="window">
|
|
<i class="fa fa-cog mr-1"></i> Actions
|
|
</button>
|
|
<div class="dropdown-menu">
|
|
<t t-if="can_add_contact">
|
|
<a t-att-href="'/my/contacts/edit/%s' % contact.id" class="dropdown-item">
|
|
<i class="fa fa-pencil text-primary mr-2"></i> Edit
|
|
</a>
|
|
</t>
|
|
<t t-if="contact.email and not contact.user_ids and contact.active and can_add_contact">
|
|
<a t-att-href="'/my/contacts/grant_access/%s' % contact.id" class="dropdown-item">
|
|
<i class="fa fa-key text-success mr-2"></i> Grant Portal Access
|
|
</a>
|
|
</t>
|
|
<t t-if="not (contact.user_ids and contact.active)">
|
|
<a t-att-href="'/my/contacts/change_status/%s?status=portal' % contact.id" class="dropdown-item">
|
|
<i class="fa fa-check text-success mr-2"></i> Portal Access
|
|
</a>
|
|
</t>
|
|
<t t-if="not (not contact.user_ids and contact.active)">
|
|
<a t-att-href="'/my/contacts/change_status/%s?status=no_access' % contact.id" class="dropdown-item">
|
|
<i class="fa fa-user-o text-secondary mr-2"></i> No Access
|
|
</a>
|
|
</t>
|
|
<t t-if="contact.active">
|
|
<a t-att-href="'/my/contacts/change_status/%s?status=archived' % contact.id" class="dropdown-item">
|
|
<i class="fa fa-archive text-danger mr-2"></i> Archive
|
|
</a>
|
|
</t>
|
|
<t t-if="not contact.active">
|
|
<a t-att-href="'/my/contacts/change_status/%s?status=no_access' % contact.id" class="dropdown-item">
|
|
<i class="fa fa-undo text-success mr-2"></i> Unarchive
|
|
</a>
|
|
</t>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</t>
|
|
</div>
|
|
<div class="o_portal_pager mt-3">
|
|
<t t-call="portal.pager"/>
|
|
</div>
|
|
</div>
|
|
</t>
|
|
<t t-else="">
|
|
<div class="alert alert-info">
|
|
<p>No contacts found.</p>
|
|
</div>
|
|
</t>
|
|
</div>
|
|
<div class="oe_structure" />
|
|
</div>
|
|
</t>
|
|
</template>
|
|
|
|
<!-- Template pour l'ajout d'un contact -->
|
|
<template id="portal_my_contacts_add" name="Add Contact">
|
|
<t t-call="portal.portal_layout">
|
|
<div class="o_portal_my_home">
|
|
<div class="oe_structure" />
|
|
|
|
<!-- Page title -->
|
|
<div class="o_portal_my_details">
|
|
<h3 class="page-header">
|
|
Add a Contact
|
|
</h3>
|
|
|
|
<!-- Message d'erreur -->
|
|
<t t-if="request.params.get('error') == 'email_required'">
|
|
<div class="alert alert-danger alert-dismissible fade show" role="alert">
|
|
<i class="fa fa-exclamation-triangle mr-2"></i> Email is required.
|
|
<button type="button" class="close" data-dismiss="alert" aria-label="Close">
|
|
<span aria-hidden="true">&times;</span>
|
|
</button>
|
|
</div>
|
|
</t>
|
|
<t t-elif="request.params.get('error')">
|
|
<div class="alert alert-danger alert-dismissible fade show" role="alert">
|
|
<i class="fa fa-exclamation-triangle mr-2"></i> An error occurred while creating the contact.
|
|
<button type="button" class="close" data-dismiss="alert" aria-label="Close">
|
|
<span aria-hidden="true">&times;</span>
|
|
</button>
|
|
</div>
|
|
</t>
|
|
|
|
<!-- Formulaire d'ajout -->
|
|
<form action="/my/contacts/create" method="post" class="mt-4 o_portal_details">
|
|
<input type="hidden" name="csrf_token" t-att-value="request.csrf_token()"/>
|
|
|
|
<div class="card">
|
|
<div class="card-header bg-primary text-white">
|
|
<h5 class="mb-0">
|
|
<i class="fa fa-user mr-2"></i> New Contact
|
|
</h5>
|
|
</div>
|
|
<div class="card-body">
|
|
<div class="row">
|
|
<div class="col-lg-6">
|
|
<div class="form-group">
|
|
<label for="name">Name <span class="text-danger">*</span></label>
|
|
<input type="text" class="form-control" name="name" id="name" required="required"/>
|
|
</div>
|
|
<div class="form-group">
|
|
<label for="email">Email <span class="text-danger email-required">*</span></label>
|
|
<input type="email" class="form-control" name="email" id="email"/>
|
|
</div>
|
|
<div class="form-group">
|
|
<label for="phone">Phone</label>
|
|
<input type="tel" class="form-control" name="phone" id="phone"/>
|
|
</div>
|
|
<div class="form-group">
|
|
<label for="mobile">Mobile</label>
|
|
<input type="tel" class="form-control" name="mobile" id="mobile"/>
|
|
</div>
|
|
<div class="form-group">
|
|
<label for="type">Contact Type</label>
|
|
<select class="form-control" name="type" id="type" onchange="toggleContactFields(this.value)">
|
|
<option value="contact" selected="selected">Contact</option>
|
|
<option value="invoice">Billing Address</option>
|
|
<option value="delivery">Shipping Address</option>
|
|
<option value="origin">Origin Address</option>
|
|
<option value="other">Other Address</option>
|
|
</select>
|
|
</div>
|
|
</div>
|
|
<div class="col-lg-6">
|
|
<div class="form-group address-field">
|
|
<label for="street">Address</label>
|
|
<input type="text" class="form-control" name="street" id="street"/>
|
|
</div>
|
|
<div class="form-group address-field">
|
|
<label for="city">City</label>
|
|
<input type="text" class="form-control" name="city" id="city"/>
|
|
</div>
|
|
<div class="form-group address-field">
|
|
<label for="zip">Zip Code</label>
|
|
<input type="text" class="form-control" name="zip" id="zip"/>
|
|
</div>
|
|
<div class="form-group">
|
|
<label for="country_id">Country</label>
|
|
<select class="form-control" name="country_id" id="country_id" disabled="disabled">
|
|
<t t-foreach="countries" t-as="country">
|
|
<option t-att-value="country.id" t-att-selected="country.code == 'CA'">
|
|
<t t-esc="country.name"/>
|
|
</option>
|
|
</t>
|
|
</select>
|
|
<!-- Champ caché pour s'assurer que la valeur est envoyée même si le champ est désactivé -->
|
|
<input type="hidden" name="country_id" t-att-value="canada and canada.id or ''"/>
|
|
</div>
|
|
<div class="form-group" id="states_container">
|
|
<label for="state_id">Province</label>
|
|
<select class="form-control" name="state_id" id="state_id">
|
|
<t t-foreach="canadian_provinces" t-as="province">
|
|
<option t-att-value="province.id" t-att-selected="province.code == 'QC'">
|
|
<t t-esc="province.name"/>
|
|
</option>
|
|
</t>
|
|
</select>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div class="card-footer">
|
|
<div class="d-flex justify-content-between">
|
|
<a href="/my/company" class="btn btn-secondary">
|
|
<i class="fa fa-arrow-left mr-1"></i> Cancel
|
|
</a>
|
|
<button type="submit" class="btn btn-primary">
|
|
<i class="fa fa-save mr-1"></i> Create
|
|
</button>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</form>
|
|
</div>
|
|
<div class="oe_structure" />
|
|
</div>
|
|
</t>
|
|
</template>
|
|
|
|
<!-- Template for editing a contact -->
|
|
<template id="portal_my_contacts_edit" name="Edit Contact">
|
|
<t t-call="portal.portal_layout">
|
|
<div class="o_portal_my_home">
|
|
<div class="oe_structure" />
|
|
|
|
<!-- Page title -->
|
|
<div class="o_portal_my_details">
|
|
<h3 class="page-header">
|
|
Edit Contact: <span t-field="contact.name"/>
|
|
</h3>
|
|
|
|
<!-- Message d'erreur -->
|
|
<t t-if="request.params.get('error')">
|
|
<div class="alert alert-danger alert-dismissible fade show" role="alert">
|
|
<i class="fa fa-exclamation-triangle mr-2"></i> An error occurred while updating the contact.
|
|
<button type="button" class="close" data-dismiss="alert" aria-label="Close">
|
|
<span aria-hidden="true">&times;</span>
|
|
</button>
|
|
</div>
|
|
</t>
|
|
|
|
<!-- Formulaire d'édition -->
|
|
<form action="/my/contacts/update" method="post" class="mt-4 o_portal_details">
|
|
<input type="hidden" name="csrf_token" t-att-value="request.csrf_token()"/>
|
|
<input type="hidden" name="contact_id" t-att-value="contact.id"/>
|
|
|
|
<div class="card">
|
|
<div class="card-header bg-primary text-white">
|
|
<h5 class="mb-0">
|
|
<i class="fa fa-user mr-2"></i> Contact Information
|
|
</h5>
|
|
</div>
|
|
<div class="card-body">
|
|
<div class="row">
|
|
<div class="col-lg-6">
|
|
<div class="form-group">
|
|
<label for="name">Name <span class="text-danger">*</span></label>
|
|
<input type="text" class="form-control" name="name" id="name" t-att-value="contact.name" required="required"/>
|
|
</div>
|
|
<div class="form-group">
|
|
<label for="email">Email <span class="text-danger email-required">*</span></label>
|
|
<input type="email" class="form-control" name="email" id="email" t-att-value="contact.email"/>
|
|
</div>
|
|
<div class="form-group">
|
|
<label for="phone">Phone</label>
|
|
<input type="tel" class="form-control" name="phone" id="phone" t-att-value="contact.phone"/>
|
|
</div>
|
|
<div class="form-group">
|
|
<label for="mobile">Mobile</label>
|
|
<input type="tel" class="form-control" name="mobile" id="mobile" t-att-value="contact.mobile"/>
|
|
</div>
|
|
<div class="form-group">
|
|
<label for="type">Contact Type</label>
|
|
<select class="form-control" name="type" id="type" onchange="toggleContactFields(this.value)">
|
|
<option value="contact" t-att-selected="contact.type == 'contact' or not contact.type">Contact</option>
|
|
<option value="invoice" t-att-selected="contact.type == 'invoice'">Billing Address</option>
|
|
<option value="delivery" t-att-selected="contact.type == 'delivery'">Shipping Address</option>
|
|
<option value="origin" t-att-selected="contact.type == 'origin'">Origin Address</option>
|
|
<option value="other" t-att-selected="contact.type == 'other'">Other Address</option>
|
|
</select>
|
|
</div>
|
|
</div>
|
|
<div class="col-lg-6">
|
|
<div class="form-group address-field">
|
|
<label for="street">Address</label>
|
|
<input type="text" class="form-control" name="street" id="street" t-att-value="contact.street"/>
|
|
</div>
|
|
<div class="form-group address-field">
|
|
<label for="city">City</label>
|
|
<input type="text" class="form-control" name="city" id="city" t-att-value="contact.city"/>
|
|
</div>
|
|
<div class="form-group address-field">
|
|
<label for="zip">Zip Code</label>
|
|
<input type="text" class="form-control" name="zip" id="zip" t-att-value="contact.zip"/>
|
|
</div>
|
|
<div class="form-group">
|
|
<label for="country_id">Country</label>
|
|
<select class="form-control" name="country_id" id="country_id" disabled="disabled">
|
|
<t t-foreach="countries" t-as="country">
|
|
<option t-att-value="country.id" t-att-selected="country.id == contact.country_id.id or (not contact.country_id and country.code == 'CA')">
|
|
<t t-esc="country.name"/>
|
|
</option>
|
|
</t>
|
|
</select>
|
|
<!-- Champ caché pour s'assurer que la valeur est envoyée même si le champ est désactivé -->
|
|
<input type="hidden" name="country_id" t-att-value="canada and canada.id or ''"/>
|
|
</div>
|
|
<div class="form-group">
|
|
<label for="state_id">Province</label>
|
|
<select class="form-control" name="state_id" id="state_id" t-att-data-value="contact.state_id.id">
|
|
<t t-foreach="canadian_provinces" t-as="province">
|
|
<option t-att-value="province.id" t-att-selected="province.id == contact.state_id.id or (not contact.state_id and province.code == 'QC')">
|
|
<t t-esc="province.name"/>
|
|
</option>
|
|
</t>
|
|
</select>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div class="card-footer">
|
|
<div class="d-flex justify-content-between">
|
|
<a href="/my/company" class="btn btn-secondary">
|
|
<i class="fa fa-arrow-left mr-1"></i> Cancel
|
|
</a>
|
|
<button type="submit" class="btn btn-primary">
|
|
<i class="fa fa-save mr-1"></i> Save
|
|
</button>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</form>
|
|
</div>
|
|
<div class="oe_structure" />
|
|
</div>
|
|
</t>
|
|
</template>
|
|
<template id="contact_form_scripts" name="Contact Form Scripts" inherit_id="portal_my_contacts_add">
|
|
<xpath expr="//div[hasclass('oe_structure')][last()]" position="after">
|
|
<script type="text/javascript">
|
|
function toggleContactFields(type) {
|
|
// Handle email required field
|
|
var emailInput = document.getElementById('email');
|
|
var emailRequired = document.querySelector('.email-required');
|
|
|
|
if (type === 'contact') {
|
|
// Make email required for contact type
|
|
emailInput.setAttribute('required', 'required');
|
|
emailRequired.style.display = '';
|
|
|
|
// Hide address fields for contact type
|
|
var addressFields = document.querySelectorAll('.address-field');
|
|
addressFields.forEach(function(field) {
|
|
field.style.display = 'none';
|
|
});
|
|
} else {
|
|
// Make email optional for other types
|
|
// Force remove the required attribute
|
|
emailInput.required = false;
|
|
emailInput.removeAttribute('required');
|
|
emailRequired.style.display = 'none';
|
|
|
|
// Show address fields for non-contact types
|
|
var addressFields = document.querySelectorAll('.address-field');
|
|
addressFields.forEach(function(field) {
|
|
field.style.display = '';
|
|
});
|
|
}
|
|
}
|
|
|
|
// Run on page load
|
|
document.addEventListener('DOMContentLoaded', function() {
|
|
var typeSelect = document.getElementById('type');
|
|
if (typeSelect) {
|
|
toggleContactFields(typeSelect.value);
|
|
}
|
|
});
|
|
</script>
|
|
</xpath>
|
|
</template>
|
|
|
|
<template id="contact_edit_form_scripts" name="Contact Edit Form Scripts" inherit_id="portal_my_contacts_edit">
|
|
<xpath expr="//div[hasclass('oe_structure')][last()]" position="after">
|
|
<script type="text/javascript">
|
|
function toggleContactFields(type) {
|
|
// Handle email required field
|
|
var emailInput = document.getElementById('email');
|
|
var emailRequired = document.querySelector('.email-required');
|
|
|
|
if (type === 'contact') {
|
|
// Make email required for contact type
|
|
emailInput.setAttribute('required', 'required');
|
|
emailRequired.style.display = '';
|
|
|
|
// Hide address fields for contact type
|
|
var addressFields = document.querySelectorAll('.address-field');
|
|
addressFields.forEach(function(field) {
|
|
field.style.display = 'none';
|
|
});
|
|
} else {
|
|
// Make email optional for other types
|
|
// Force remove the required attribute
|
|
emailInput.required = false;
|
|
emailInput.removeAttribute('required');
|
|
emailRequired.style.display = 'none';
|
|
|
|
// Show address fields for non-contact types
|
|
var addressFields = document.querySelectorAll('.address-field');
|
|
addressFields.forEach(function(field) {
|
|
field.style.display = '';
|
|
});
|
|
}
|
|
}
|
|
|
|
// Run on page load
|
|
document.addEventListener('DOMContentLoaded', function() {
|
|
var typeSelect = document.getElementById('type');
|
|
if (typeSelect) {
|
|
toggleContactFields(typeSelect.value);
|
|
}
|
|
});
|
|
</script>
|
|
</xpath>
|
|
</template>
|
|
</odoo>
|