Skip to content

Commit

Permalink
[IMP] base, l10n_jp: titles on contact.
Browse files Browse the repository at this point in the history
In multiple countries, adding honorifics near the names of your customer/vendor/…
is seen as basic politeness and not doing so is considered rude.
One well-known example is Japan, Korea is another country with similar needs.

As of today, Odoo has no way to do that easily, and users have no choice but
to use Studio to customize the reports manually.

This feature aim to improve that by providing a standard way of providing titles
when sending documents to your contacts.

This is done by adding the title to the contact qweb widget by default if it is
set on the contact record.
This also adds a new field on the title model in order to define whether the title
should be a prefix or a suffix.

Note that this is a simple, naive approach that may not fit all scenarios perfectly.

task id # 3272592
  • Loading branch information
vin-odoo committed May 20, 2024
1 parent 7825d50 commit e5d6a89
Show file tree
Hide file tree
Showing 6 changed files with 51 additions and 0 deletions.
2 changes: 2 additions & 0 deletions addons/l10n_jp/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@
'auto_install': ['account'],
'data': [
'data/account_tax_report_data.xml',
'data/res_partner_title_data.xml',
'views/res_partner_views.xml',
],
'demo': [
'demo/demo_company.xml',
Expand Down
20 changes: 20 additions & 0 deletions addons/l10n_jp/data/res_partner_title_data.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo noupdate="True">
<!-- These are set directly in japanese, are you cannot really translate english in all cases. -->
<record id="res_partner_title_sama" model="res.partner.title">
<field name="name">様</field>
<field name="position">after</field>
</record>
<record id="res_partner_title_sensei" model="res.partner.title">
<field name="name">先生</field>
<field name="position">after</field>
</record>
<record id="res_partner_title_hakase" model="res.partner.title">
<field name="name">博士</field>
<field name="position">after</field>
</record>
<record id="res_partner_title_onchu" model="res.partner.title">
<field name="name">御中</field>
<field name="position">after</field>
</record>
</odoo>
14 changes: 14 additions & 0 deletions addons/l10n_jp/views/res_partner_views.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<record id="res_partner_view_form" model="ir.ui.view">
<field name="name">res.partner.form</field>
<field name="model">res.partner</field>
<field name="inherit_id" ref="account.view_partner_property_form"/>
<field name="arch" type="xml">
<!-- in Japan, honorifics should also be added to companies. -->
<field name="title" position="attributes">
<attribute name="invisible">is_company and country_code != 'JP'</attribute>
</field>
</field>
</record>
</odoo>
1 change: 1 addition & 0 deletions odoo/addons/base/models/ir_qweb_fields.py
Original file line number Diff line number Diff line change
Expand Up @@ -779,6 +779,7 @@ def get_available_options(self):
no_tag_br=dict(type='boolean', string=_('Use comma'), description=_("Use comma instead of the <br> tag to display the address")),
phone_icons=dict(type='boolean', string=_('Display phone icons'), description=_("Display the phone icons even if no_marker is True")),
country_image=dict(type='boolean', string=_('Display country image'), description=_("Display the country image if the field is present on the record")),
no_title=dict(type='boolean', string=_('Hide title'), description=_("Hide the title when the field is present on the record"), default_value=False),
)
return options

Expand Down
8 changes: 8 additions & 0 deletions odoo/addons/base/models/res_partner.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,14 @@ class PartnerTitle(models.Model):

name = fields.Char(string='Title', required=True, translate=True)
shortcut = fields.Char(string='Abbreviation', translate=True)
position = fields.Selection(
selection=[
('before', 'Before Name'),
('after', 'After Name'),
],
help='Select if the title should be displayed before or after the partner name.',
default='before',
)


class Partner(models.Model):
Expand Down
6 changes: 6 additions & 0 deletions odoo/addons/base/views/ir_qweb_widget_templates.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,18 @@

<template id="contact_name">
<div t-if="'name' in fields">
<t t-if="not options.get('no_title') and object.title and object.title.position == 'before'">
<span itemprop="title" t-esc="object.title.shortcut or object.title.name"/>
</t>
<t t-if="object.name">
<span itemprop="name" t-esc="name"/>
</t>
<t t-if="not object.name and object.parent_name">
<span itemprop="name" t-esc="object.parent_name"/>
</t>
<t t-if="not options.get('no_title') and object.title and object.title.position == 'after'">
<span itemprop="title" t-esc="object.title.shortcut or object.title.name"/>
</t>
<t t-if="options.get('country_image') and 'country_id' in fields and object.country_id and object.country_id.image_url">
<span t-field="object.country_id.image_url" t-options='{"widget": "image_url", "class": "country_flag"}'/>
</t>
Expand Down

0 comments on commit e5d6a89

Please sign in to comment.