From 8a2fc8104f414310d7f0cd8d8f7ea7dce94501d0 Mon Sep 17 00:00:00 2001 From: "Nicolas Viseur (vin)" Date: Mon, 13 May 2024 13:36:13 +0800 Subject: [PATCH] [IMP] base, l10n_jp: titles on contact. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- addons/l10n_jp/__manifest__.py | 2 ++ .../l10n_jp/data/res_partner_title_data.xml | 20 +++++++++++++++++++ addons/l10n_jp/views/res_partner_views.xml | 14 +++++++++++++ odoo/addons/base/models/ir_qweb_fields.py | 1 + odoo/addons/base/models/res_partner.py | 8 ++++++++ .../base/views/ir_qweb_widget_templates.xml | 6 ++++++ 6 files changed, 51 insertions(+) create mode 100644 addons/l10n_jp/data/res_partner_title_data.xml create mode 100644 addons/l10n_jp/views/res_partner_views.xml diff --git a/addons/l10n_jp/__manifest__.py b/addons/l10n_jp/__manifest__.py index b1554faa53c6d..7592bf81bd517 100644 --- a/addons/l10n_jp/__manifest__.py +++ b/addons/l10n_jp/__manifest__.py @@ -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', diff --git a/addons/l10n_jp/data/res_partner_title_data.xml b/addons/l10n_jp/data/res_partner_title_data.xml new file mode 100644 index 0000000000000..7b391beddf928 --- /dev/null +++ b/addons/l10n_jp/data/res_partner_title_data.xml @@ -0,0 +1,20 @@ + + + + + + after + + + 先生 + after + + + 博士 + after + + + 御中 + after + + diff --git a/addons/l10n_jp/views/res_partner_views.xml b/addons/l10n_jp/views/res_partner_views.xml new file mode 100644 index 0000000000000..527f94196ee57 --- /dev/null +++ b/addons/l10n_jp/views/res_partner_views.xml @@ -0,0 +1,14 @@ + + + + res.partner.form + res.partner + + + + + is_company and country_code != 'JP' + + + + diff --git a/odoo/addons/base/models/ir_qweb_fields.py b/odoo/addons/base/models/ir_qweb_fields.py index a8c2bd93bd36e..1e74d2a0725fc 100644 --- a/odoo/addons/base/models/ir_qweb_fields.py +++ b/odoo/addons/base/models/ir_qweb_fields.py @@ -779,6 +779,7 @@ def get_available_options(self): no_tag_br=dict(type='boolean', string=_('Use comma'), description=_("Use comma instead of the
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 diff --git a/odoo/addons/base/models/res_partner.py b/odoo/addons/base/models/res_partner.py index 622a1695a0ff1..9303fbf076ec3 100644 --- a/odoo/addons/base/models/res_partner.py +++ b/odoo/addons/base/models/res_partner.py @@ -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): diff --git a/odoo/addons/base/views/ir_qweb_widget_templates.xml b/odoo/addons/base/views/ir_qweb_widget_templates.xml index cd00bb7664885..caa0d81503b92 100644 --- a/odoo/addons/base/views/ir_qweb_widget_templates.xml +++ b/odoo/addons/base/views/ir_qweb_widget_templates.xml @@ -2,12 +2,18 @@