Skip to content

Commit

Permalink
[FIX] web,*: phone number ltr even in rtl language
Browse files Browse the repository at this point in the history
Currently there is two ways in view to have a phone number displayed in
LTR in a RTL language:

- have `widget="phone"` on a field
- have a class o_force_ltr on the field

But this is currently done very rarely and fail in list view because the
direction of data cells is used, eg.:

```
<div style="direction:rtl">
  <table><tr><td style="direction:ltr">
      <span>+1 2 3</span>
  </td></tr><tr><td>
      <span style="direction:ltr">+4 5 6</span>
  </td>/tr></table>
</div>
```

will be displayed as:

+1 2 3
6 5 4+

In this commit, we use unicode-bidi* to optionally add an additional
level of embedding so direction is taken into account by the
bidirectional algorithm.

This commit also adds o_force_ltr class or phone widget on phone fields
where it is not already defined.

*: https://drafts.csswg.org/css-writing-modes-3/#propdef-unicode-bidi

opw-2224828
closes odoo#48425

closes odoo#48464

X-original-commit: 2bc0b5f
Signed-off-by: Nicolas Lempereur (nle) <[email protected]>
  • Loading branch information
nle-odoo committed Mar 27, 2020
1 parent 88f420f commit 62c3f8c
Show file tree
Hide file tree
Showing 18 changed files with 33 additions and 32 deletions.
4 changes: 2 additions & 2 deletions addons/crm/views/crm_lead_views.xml
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,7 @@
<field name="contact_name" optional="show"/>
<field name="partner_name" optional="hide"/>
<field name="email_from" optional="show"/>
<field name="phone" optional="show"/>
<field name="phone" optional="show" class="o_force_ltr"/>
<field name="city" optional="show"/>
<field name="state_id" optional="hide"/>
<field name="country_id" optional="show"/>
Expand Down Expand Up @@ -585,7 +585,7 @@
<field name="name" string="Opportunity"/>
<field name="partner_id" string="Customer" optional="show"/>
<field name="email_from" optional="hide"/>
<field name="phone" optional="hide"/>
<field name="phone" class="o_force_ltr" optional="hide"/>
<field name="city" optional="hide"/>
<field name="state_id" optional="hide"/>
<field name="country_id" optional="show"/>
Expand Down
4 changes: 2 additions & 2 deletions addons/crm/wizard/crm_lead_to_opportunity_views.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
<field name="contact_name"/>
<field name="country_id" invisible="context.get('invisible_country', True)"/>
<field name="email_from"/>
<field name="phone"/>
<field name="phone" class="o_force_ltr"/>
<field name="stage_id"/>
<field name="user_id"/>
<field name="team_id" kanban_view_ref="%(sales_team.crm_team_view_kanban)s"/>
Expand Down Expand Up @@ -68,7 +68,7 @@
<field name="contact_name"/>
<field name="country_id" invisible="context.get('invisible_country', True)"/>
<field name="email_from"/>
<field name="phone"/>
<field name="phone" class="o_force_ltr"/>
<field name="stage_id"/>
<field name="user_id"/>
<field name="team_id"/>
Expand Down
2 changes: 1 addition & 1 deletion addons/crm/wizard/crm_merge_opportunities_views.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
<field name="type"/>
<field name="contact_name"/>
<field name="email_from"/>
<field name="phone"/>
<field name="phone" class="o_force_ltr"/>
<field name="stage_id"/>
<field name="user_id"/>
<field name="team_id"/>
Expand Down
4 changes: 2 additions & 2 deletions addons/event/views/event_views.xml
Original file line number Diff line number Diff line change
Expand Up @@ -494,8 +494,8 @@
<field name="partner_id" attrs="{'readonly':[('state', '!=', 'draft')]}"/>
<field name="name"/>
<field name="email"/>
<field name="phone"/>
<field name="mobile"/>
<field name="phone" class="o_force_ltr"/>
<field name="mobile" class="o_force_ltr"/>
</group>
<group string="Event Information" name="event">
<field name="event_id" attrs="{'readonly': [('state', '!=', 'draft')]}" options="{'no_create': True}"/>
Expand Down
4 changes: 2 additions & 2 deletions addons/event_sale/wizard/event_edit_registration.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
<field name="event_ticket_id" domain="[('event_id', '=', event_id)]" readonly='1' force_save="1"/>
<field name="name"/>
<field name="email"/>
<field name="mobile"/>
<field name="phone"/>
<field name="mobile" class="o_force_ltr"/>
<field name="phone" class="o_force_ltr"/>
</tree>
</field>
<footer>
Expand Down
4 changes: 2 additions & 2 deletions addons/hr/views/hr_employee_public_views.xml
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@
<field name="arch" type="xml">
<tree string="Employees">
<field name="name"/>
<field name="work_phone"/>
<field name="work_phone" class="o_force_ltr"/>
<field name="work_email"/>
<field name="company_id" groups="base.group_multi_company"/>
<field name="department_id"/>
Expand Down Expand Up @@ -136,7 +136,7 @@
<ul>
<li id="last_login"/>
<li t-if="record.work_email.raw_value"><field name="work_email" /></li>
<li t-if="record.work_phone.raw_value"><field name="work_phone" /></li>
<li t-if="record.work_phone.raw_value" class="o_force_ltr"><field name="work_phone" /></li>
</ul>
</div>
</div>
Expand Down
10 changes: 5 additions & 5 deletions addons/hr/views/hr_employee_views.xml
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@
'form_view_ref': 'base.res_partner_view_form_private'}"
options='{"always_reload": True, "highlight_first_line": True}'/>
<field name="private_email" string="Email"/>
<field name="phone" groups="hr.group_hr_user" string="Phone"/>
<field name="phone" class="o_force_ltr" groups="hr.group_hr_user" string="Phone"/>
<field name="bank_account_id" context="{'default_partner_id': address_home_id}"/>
<field name="km_home_work" groups="hr.group_hr_user"/>
</group>
Expand All @@ -154,7 +154,7 @@
</group>
<group string="Emergency">
<field name="emergency_contact"/>
<field name="emergency_phone"/>
<field name="emergency_phone" class="o_force_ltr"/>
</group>
<group string="Work Permit" name="work_permit">
<field name="visa_no"/>
Expand Down Expand Up @@ -202,7 +202,7 @@
<field name="arch" type="xml">
<tree string="Employees">
<field name="name"/>
<field name="work_phone"/>
<field name="work_phone" class="o_force_ltr"/>
<field name="work_email"/>
<field name="company_id" groups="base.group_multi_company"/>
<field name="department_id"/>
Expand Down Expand Up @@ -248,7 +248,7 @@
<ul>
<li id="last_login"/>
<li t-if="record.work_email.raw_value" class="o_text_overflow"><field name="work_email" /></li>
<li t-if="record.work_phone.raw_value"><field name="work_phone" /></li>
<li t-if="record.work_phone.raw_value" class="o_force_ltr"><field name="work_phone" /></li>
</ul>
</div>
</div>
Expand Down Expand Up @@ -321,7 +321,7 @@
<field name="arch" type="xml">
<tree string="Employees">
<field name="name"/>
<field name="work_phone"/>
<field name="work_phone" class="o_force_ltr"/>
<field name="work_email"/>
<field name="company_id" groups="base.group_multi_company"/>
<field name="department_id"/>
Expand Down
6 changes: 3 additions & 3 deletions addons/hr/views/res_users.xml
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@
options='{"always_reload": True, "highlight_first_line": True}'
attrs="{'readonly': [('can_edit', '=', False)]}"/>
<field name="private_email" string="Email" attrs="{'readonly': [('can_edit', '=', False)]}"/>
<field name="employee_phone" string="Phone" attrs="{'readonly': [('can_edit', '=', False)]}"/>
<field name="employee_phone" string="Phone" class="o_force_ltr" attrs="{'readonly': [('can_edit', '=', False)]}"/>
<field name="employee_bank_account_id" attrs="{'readonly': [('can_edit', '=', False)]}"/>
<field name="km_home_work" attrs="{'readonly': [('can_edit', '=', False)]}"/>
</group>
Expand All @@ -166,8 +166,8 @@
<field name="children" attrs="{'readonly': [('can_edit', '=', False)]}"/>
</group>
<group string="Emergency">
<field name="emergency_contact" attrs="{'readonly': [('can_edit', '=', False)]}"/>
<field name="emergency_phone" attrs="{'readonly': [('can_edit', '=', False)]}"/>
<field name="emergency_contact" class="o_force_ltr" attrs="{'readonly': [('can_edit', '=', False)]}"/>
<field name="emergency_phone" class="o_force_ltr" attrs="{'readonly': [('can_edit', '=', False)]}"/>
</group>
<group string="Work Permit" name="work_permit">
<field name="visa_no" attrs="{'readonly': [('can_edit', '=', False)]}"/>
Expand Down
2 changes: 1 addition & 1 deletion addons/hr_recruitment/views/hr_recruitment_views.xml
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,7 @@
</div>
</div>
<field name="categ_ids" widget="many2many_tags" options="{'color_field': 'color'}"/>
<t t-if="record.partner_mobile.raw_value"><i class="fa fa-mobile mr4" role="img" aria-label="Mobile" title="Mobile"/><field name="partner_mobile" widget ="phone"/><br/></t>
<t t-if="record.partner_mobile.raw_value"><i class="fa fa-mobile mr4" role="img" aria-label="Mobile" title="Mobile"/><field name="partner_mobile" widget="phone"/><br/></t>
<div class="o_kanban_record_bottom mt4">
<div class="oe_kanban_bottom_left">
<div class="float-left mr4" groups="base.group_user">
Expand Down
4 changes: 2 additions & 2 deletions addons/lunch/views/lunch_supplier_views.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<field name="arch" type="xml">
<tree>
<field name="name"/>
<field name="phone"/>
<field name="phone" class="o_force_ltr"/>
<field name="email"/>
</tree>
</field>
Expand Down Expand Up @@ -39,7 +39,7 @@
<group>
<field name="active" invisible="1"/>
<field name="email" attrs="{'required': [('send_by', '=', 'mail')]}"/>
<field name="phone" attrs="{'required': [('send_by', '=', 'phone')]}"/>
<field name="phone" class="o_force_ltr" attrs="{'required': [('send_by', '=', 'phone')]}"/>
<field name="company_id" groups="base.group_multi_company"/>
<field name="responsible_id" attrs="{'required': [('send_by', '=', 'mail')]}" groups="base.group_no_one"/>
</group>
Expand Down
4 changes: 2 additions & 2 deletions addons/mass_mailing_sms/views/mailing_contact_views.xml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
<field name="create_date"/>
<field name="name"/>
<field name="company_name"/>
<field name="mobile"/>
<field name="mobile" class="o_force_ltr"/>
<field name="phone_sanitized" invisible="1"/>
<field name="phone_blacklisted"/>
<field name="opt_out" invisible="'default_list_ids' not in context"/>
Expand Down Expand Up @@ -64,7 +64,7 @@
<field name="inherit_id" ref="mass_mailing.view_mail_mass_mailing_contact_kanban"/>
<field name="arch" type="xml">
<xpath expr="//field[@name='email']" position="after">
<field name="mobile"/>
<field name="mobile" class="o_force_ltr"/>
<field name="phone_sanitized" invisible="1"/>
</xpath>
<xpath expr="//t[@t-esc='record.email.value']" position="after">
Expand Down
1 change: 1 addition & 0 deletions addons/web/static/src/scss/ui.scss
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ span.o_force_ltr {
display: inline-block;
}
.o_force_ltr, .o_field_phone {
unicode-bidi: embed; // ensure element has level of embedding for direction
/*rtl:ignore*/
direction: ltr;
}
Expand Down
2 changes: 1 addition & 1 deletion addons/website/views/website_visitor_views.xml
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@
<field name="is_connected" invisible="1"/>
<field name="partner_id" attrs="{'invisible': [('partner_id', '=', False)]}"/>
<field name="email"/>
<field name="mobile"/>
<field name="mobile" class="o_force_ltr"/>
<field name="country_id" attrs="{'invisible': [('country_id', '=', False)]}"/>
<field name="lang_id"/>
</group>
Expand Down
2 changes: 1 addition & 1 deletion addons/website_event_track/views/event_track_views.xml
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@
<field name="partner_id" domain="['|', ('company_id', '=', company_id), ('company_id', '=', False)]"/>
<field name="partner_name"/>
<field name="partner_email"/>
<field name="partner_phone"/>
<field name="partner_phone" class="o_force_ltr"/>
<field name="partner_biography"/>
</group>
</page>
Expand Down
2 changes: 1 addition & 1 deletion addons/website_sms/views/website_visitor_views.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
<field name="inherit_id" ref="website.website_visitor_view_kanban"/>
<field name="arch" type="xml">
<field name="page_ids" position="after">
<field name="mobile"/>
<field name="mobile" widget="phone"/>
</field>
<xpath expr="//div[hasclass('w_visitor_kanban_actions')]" position="inside">
<button name="action_send_sms" type="object" class="btn btn-secondary"
Expand Down
2 changes: 1 addition & 1 deletion odoo/addons/base/views/res_bank_views.xml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
</div>
</group>
<group name="communication_details">
<field name="phone"/>
<field name="phone" class="o_force_ltr"/>
<field name="email" widget="email"/>
<field name="active" invisible="1"/>
</group>
Expand Down
6 changes: 3 additions & 3 deletions odoo/addons/base/views/res_company_views.xml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
<field name="zip" placeholder="ZIP" class="o_address_zip"/>
<field name="country_id" placeholder="Country" class="o_address_country" options='{"no_open": True}'/>
</div>
<field name="phone"/>
<field name="phone" class="o_force_ltr"/>
<field name="email"/>
<field name="website" string="Website" widget="url" placeholder="e.g. https://www.odoo.com"/>
</group>
Expand Down Expand Up @@ -84,7 +84,7 @@
<div t-if="record.email.value" class="col-6 text-center">
<field name="email"/>
</div>
<div t-if="record.phone.value" class="col-6 text-center">
<div t-if="record.phone.value" class="col-6 text-center o_force_ltr">
<field name="phone"/>
</div>
</div>
Expand All @@ -93,7 +93,7 @@
<strong>Email:</strong>
<field name="email"/>
</div>
<div t-if="record.phone.value">
<div t-if="record.phone.value" class="o_force_ltr">
<strong>Phone:</strong>
<field name="phone"/>
</div>
Expand Down
2 changes: 1 addition & 1 deletion odoo/addons/base/views/res_partner_views.xml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
<tree string="Contacts">
<field name="display_name" string="Name"/>
<field name="function" invisible="1"/>
<field name="phone" optional="show"/>
<field name="phone" class="o_force_ltr" optional="show"/>
<field name="email" optional="show"/>
<field name="company_id" groups="base.group_multi_company"/>
<field name="city" optional="hide"/>
Expand Down

0 comments on commit 62c3f8c

Please sign in to comment.