[FIX] portal, website_sale: translatable and responsive help text

This help text is invisible in mobiles, where you can't "hover" to see an input's `title`.

Also it was impossible to translate due to the way it was written.

Now it's usable and translatable. Uses a small help text as explained in https://getbootstrap.com/docs/4.1/components/forms/#overview

@Tecnativa TT17694

this commit closes #51152

closes odoo/odoo#62690

Signed-off-by: Jérémy Kersten (jke) <jke@openerp.com>
This commit is contained in:
Jairo Llopis
2020-12-01 14:06:57 +00:00
committed by Jeremy Kersten
parent 6d810c6004
commit beb50e8047
2 changed files with 21 additions and 9 deletions
+11 -5
View File
@@ -376,17 +376,23 @@
</div>
<div class="clearfix" />
<div t-attf-class="form-group #{error.get('company_name') and 'o_has_error' or ''} col-xl-6">
<div t-attf-class="form-group mb-1 #{error.get('company_name') and 'o_has_error' or ''} col-xl-6">
<label class="col-form-label label-optional" for="company_name">Company Name</label>
<!-- The <input> is replace by a <p> to avoid sending an unauthorized value on form submit.
The user might not have rights to change company_name but should still be able to see it.
-->
<p t-if="not partner_can_edit_vat" t-attf-class="form-control" readonly="1" t-esc="partner.commercial_company_name" title="Changing company name is not allowed once document(s) have been issued for your account. Please contact us directly for this operation."/>
<input t-else="" type="text" name="company_name" t-attf-class="form-control #{error.get('company_name') and 'is-invalid' or ''}" t-att-value="company_name or partner.commercial_company_name"/>
<input type="text" name="company_name" t-attf-class="form-control #{error.get('company_name') and 'is-invalid' or ''}" t-att-value="company_name or partner.commercial_company_name" t-att-readonly="None if partner_can_edit_vat else '1'" />
<small t-if="not partner_can_edit_vat" class="form-text text-muted d-block d-xl-none">
Changing company name is not allowed once document(s) have been issued for your account. Please contact us directly for this operation.
</small>
</div>
<div t-attf-class="form-group #{error.get('vat') and 'o_has_error' or ''} col-xl-6">
<div t-attf-class="form-group mb-1 #{error.get('vat') and 'o_has_error' or ''} col-xl-6">
<label class="col-form-label label-optional" for="vat">VAT Number</label>
<input type="text" name="vat" t-attf-class="form-control #{error.get('vat') and 'is-invalid' or ''}" t-att-value="vat or partner.vat" t-att-readonly="None if partner_can_edit_vat else '1'" t-att-title="None if partner_can_edit_vat else 'Changing VAT number is not allowed once document(s) have been issued for your account. Please contact us directly for this operation.'" />
<input type="text" name="vat" t-attf-class="form-control #{error.get('vat') and 'is-invalid' or ''}" t-att-value="vat or partner.vat" t-att-readonly="None if partner_can_edit_vat else '1'" />
<small t-if="not partner_can_edit_vat" class="form-text text-muted d-block d-xl-none">Changing VAT number is not allowed once document(s) have been issued for your account. Please contact us directly for this operation.</small>
</div>
<div t-if="not partner_can_edit_vat" class="col-12 d-none d-xl-block">
<small class="form-text text-muted">Changing company name or VAT number is not allowed once document(s) have been issued for your account. <br/>Please contact us directly for this operation.</small>
</div>
<div t-attf-class="form-group #{error.get('phone') and 'o_has_error' or ''} col-xl-6">
<label class="col-form-label" for="phone">Phone</label>
+10 -4
View File
@@ -1453,14 +1453,20 @@
<template id="address_b2b" inherit_id="address" name="Show b2b fields" customize_show="True">
<xpath expr="//div[@id='div_phone']" position="after">
<div class="w-100"/>
<t t-set='vat_warning' t-value="'vat' in checkout and checkout['vat'] and not can_edit_vat" />
<t t-if="mode == ('new', 'billing') or (mode == ('edit', 'billing') and (can_edit_vat or 'vat' in checkout and checkout['vat']))">
<div t-attf-class="form-group #{error.get('company_name') and 'o_has_error' or ''} col-lg-6">
<div t-attf-class="form-group #{error.get('company_name') and 'o_has_error' or ''} col-lg-6 mb-0">
<label class="col-form-label font-weight-normal label-optional" for="company_name">Company Name</label>
<input type="text" name="company_name" t-attf-class="form-control #{error.get('company_name') and 'is-invalid' or ''}" t-att-value="'commercial_company_name' in checkout and checkout['commercial_company_name'] or 'company_name' in checkout and checkout['company_name']" t-att-readonly="'1' if 'vat' in checkout and checkout['vat'] and not can_edit_vat else None" t-att-title="'Changing company name is not allowed once document(s) have been issued for your account. Please contact us directly for this operation.' if 'vat' in checkout and checkout['vat'] and not can_edit_vat else None" />
<input type="text" name="company_name" t-attf-class="form-control #{error.get('company_name') and 'is-invalid' or ''}" t-att-value="'commercial_company_name' in checkout and checkout['commercial_company_name'] or 'company_name' in checkout and checkout['company_name']" t-att-readonly="'1' if vat_warning else None" />
<small t-if="vat_warning" class="form-text text-muted d-block d-lg-none">Changing company name is not allowed once document(s) have been issued for your account. Please contact us directly for this operation.</small>
</div>
<div t-attf-class="form-group #{error.get('vat') and 'o_has_error' or ''} col-lg-6 div_vat">
<div t-attf-class="form-group #{error.get('vat') and 'o_has_error' or ''} col-lg-6 div_vat mb-0">
<label class="col-form-label font-weight-normal label-optional" for="vat">TIN / VAT </label>
<input type="text" name="vat" t-attf-class="form-control #{error.get('vat') and 'is-invalid' or ''}" t-att-value="'vat' in checkout and checkout['vat']" t-att-readonly="'1' if 'vat' in checkout and checkout['vat'] and not can_edit_vat else None" t-att-title="'Changing VAT number is not allowed once document(s) have been issued for your account. Please contact us directly for this operation.' if 'vat' in checkout and checkout['vat'] and not can_edit_vat else None" />
<input type="text" name="vat" t-attf-class="form-control #{error.get('vat') and 'is-invalid' or ''}" t-att-value="'vat' in checkout and checkout['vat']" t-att-readonly="'1' if vat_warning else None"/>
<small t-if="vat_warning" class="form-text text-muted d-block d-lg-none">Changing VAT number is not allowed once document(s) have been issued for your account. Please contact us directly for this operation.</small>
</div>
<div t-if="vat_warning" class="col-12 d-none d-lg-block mb-1">
<small class="form-text text-muted">Changing company name or VAT number is not allowed once document(s) have been issued for your account. Please contact us directly for this operation.</small>
</div>
</t>
</xpath>