Skip to content

Commit 98df951

Browse files
committed
[REV] Finish to revert OCA#1905.
Begin of the revert has been done in OCA#2263. But after comments in OCA#2263, it looks like it's better to full revert the initial PR. (Also the other module partner_type_base, will be removed in another PR OCA#2266).
1 parent f211903 commit 98df951

File tree

6 files changed

+42
-63
lines changed

6 files changed

+42
-63
lines changed

partner_firstname/README.rst

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,3 @@
1-
.. image:: https://odoo-community.org/readme-banner-image
2-
:target: https://odoo-community.org/get-involved?utm_source=readme
3-
:alt: Odoo Community Association
4-
51
================================
62
Partner first name and last name
73
================================
@@ -11,13 +7,13 @@ Partner first name and last name
117
!! This file is generated by oca-gen-addon-readme !!
128
!! changes will be overwritten. !!
139
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
14-
!! source digest: sha256:bcf53401576a235e25d371fa9fa02b35e39bab9df9045b75bf04724a72b7bed9
10+
!! source digest: sha256:224a197e758626faea4d1e92876a2039c4c17bb1d8d5acea1270f4a9b4b5e9eb
1511
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
1612
1713
.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
1814
:target: https://odoo-community.org/page/development-status
1915
:alt: Beta
20-
.. |badge2| image:: https://img.shields.io/badge/license-AGPL--3-blue.png
16+
.. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png
2117
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
2218
:alt: License: AGPL-3
2319
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fpartner--contact-lightgray.png?logo=github

partner_firstname/__manifest__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
{
77
"name": "Partner first name and last name",
88
"summary": "Split first name and last name for non company partners",
9-
"version": "18.0.5.0.0",
9+
"version": "18.0.6.0.0",
1010
"author": "Camptocamp, "
1111
"Grupo ESOC Ingeniería de Servicios, "
1212
"Tecnativa, "

partner_firstname/models/firstname_mixin.py

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -12,32 +12,20 @@ class FirstNameMixin(models.AbstractModel):
1212
" that have firstname / lastname fields."
1313
)
1414

15-
is_individual = fields.Boolean(compute="_compute_is_individual")
16-
1715
form_has_lastname_first = fields.Boolean(compute="_compute_form_has_lastname_first")
1816

1917
firstname_required = fields.Boolean(compute="_compute_firstname_lastname_required")
2018

2119
lastname_required = fields.Boolean(compute="_compute_firstname_lastname_required")
2220

23-
def _compute_is_individual(self):
24-
# By default, models that inherit 'firstname.mixin' are individual
25-
# (like hr.employee, for exemple)
26-
# Overload this function for more complex model, like res.partner.
27-
for item in self:
28-
item.is_individual = True
29-
3021
@api.depends(lambda self: self._get_fields_depend_firstname_lastname_required())
3122
def _compute_firstname_lastname_required(self):
3223
required_fields = (
3324
self.env["ir.config_parameter"]
3425
.sudo()
3526
.get_param("partner_names_required_fields")
3627
)
37-
for item in self.filtered(lambda x: not x.is_individual):
38-
item.firstname_required = False
39-
item.lastname_required = False
40-
for item in self.filtered(lambda x: x.is_individual):
28+
for item in self:
4129
item.firstname_required = not item.lastname or required_fields in [
4230
"firstname",
4331
"firstname_lastname",

partner_firstname/models/res_partner.py

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -28,14 +28,6 @@ class ResPartner(models.Model):
2828
readonly=False,
2929
)
3030

31-
@api.depends("is_company")
32-
def _compute_is_individual(self):
33-
# As a first approximation, individuals are
34-
# just non-company partners.
35-
# Overload this function to refine this algorithm.
36-
for item in self:
37-
item.is_individual = not item.is_company
38-
3931
# @api.depends(lambda self: self._get_fields_depend_firstname_lastname_required())
4032
def _compute_firstname_lastname_required(self):
4133
for partner in self.filtered(lambda x: x.is_company or not x.type == "contact"):

partner_firstname/static/description/index.html

Lines changed: 13 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<head>
44
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
55
<meta name="generator" content="Docutils: https://docutils.sourceforge.io/" />
6-
<title>README.rst</title>
6+
<title>Partner first name and last name</title>
77
<style type="text/css">
88

99
/*
@@ -360,21 +360,16 @@
360360
</style>
361361
</head>
362362
<body>
363-
<div class="document">
363+
<div class="document" id="partner-first-name-and-last-name">
364+
<h1 class="title">Partner first name and last name</h1>
364365

365-
366-
<a class="reference external image-reference" href="https://odoo-community.org/get-involved?utm_source=readme">
367-
<img alt="Odoo Community Association" src="https://odoo-community.org/readme-banner-image" />
368-
</a>
369-
<div class="section" id="partner-first-name-and-last-name">
370-
<h1>Partner first name and last name</h1>
371366
<!-- !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
372367
!! This file is generated by oca-gen-addon-readme !!
373368
!! changes will be overwritten. !!
374369
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
375-
!! source digest: sha256:bcf53401576a235e25d371fa9fa02b35e39bab9df9045b75bf04724a72b7bed9
370+
!! source digest: sha256:224a197e758626faea4d1e92876a2039c4c17bb1d8d5acea1270f4a9b4b5e9eb
376371
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
377-
<p><a class="reference external image-reference" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external image-reference" href="http://www.gnu.org/licenses/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/license-AGPL--3-blue.png" /></a> <a class="reference external image-reference" href="https://github.com/OCA/partner-contact/tree/18.0/partner_firstname"><img alt="OCA/partner-contact" src="https://img.shields.io/badge/github-OCA%2Fpartner--contact-lightgray.png?logo=github" /></a> <a class="reference external image-reference" href="https://translation.odoo-community.org/projects/partner-contact-18-0/partner-contact-18-0-partner_firstname"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external image-reference" href="https://runboat.odoo-community.org/builds?repo=OCA/partner-contact&amp;target_branch=18.0"><img alt="Try me on Runboat" src="https://img.shields.io/badge/runboat-Try%20me-875A7B.png" /></a></p>
372+
<p><a class="reference external image-reference" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external image-reference" href="http://www.gnu.org/licenses/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/licence-AGPL--3-blue.png" /></a> <a class="reference external image-reference" href="https://github.com/OCA/partner-contact/tree/18.0/partner_firstname"><img alt="OCA/partner-contact" src="https://img.shields.io/badge/github-OCA%2Fpartner--contact-lightgray.png?logo=github" /></a> <a class="reference external image-reference" href="https://translation.odoo-community.org/projects/partner-contact-18-0/partner-contact-18-0-partner_firstname"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external image-reference" href="https://runboat.odoo-community.org/builds?repo=OCA/partner-contact&amp;target_branch=18.0"><img alt="Try me on Runboat" src="https://img.shields.io/badge/runboat-Try%20me-875A7B.png" /></a></p>
378373
<p>This module was written to extend the functionality of contacts to
379374
support having separate last name and first name.</p>
380375
<p><strong>Table of contents</strong></p>
@@ -393,7 +388,7 @@ <h1>Partner first name and last name</h1>
393388
</ul>
394389
</div>
395390
<div class="section" id="configuration">
396-
<h2><a class="toc-backref" href="#toc-entry-1">Configuration</a></h2>
391+
<h1><a class="toc-backref" href="#toc-entry-1">Configuration</a></h1>
397392
<p><strong>Fields Order</strong></p>
398393
<p>You can configure some common name patterns for the inverse function in
399394
Settings &gt; General settings:</p>
@@ -419,7 +414,7 @@ <h2><a class="toc-backref" href="#toc-entry-1">Configuration</a></h2>
419414
<p><img alt="partner_names_required_fields" src="https://raw.githubusercontent.com/OCA/partner-contact/18.0/partner_firstname/static/description/partner_names_required_fields.png" /></p>
420415
</div>
421416
<div class="section" id="usage">
422-
<h2><a class="toc-backref" href="#toc-entry-2">Usage</a></h2>
417+
<h1><a class="toc-backref" href="#toc-entry-2">Usage</a></h1>
423418
<p>The field <em>name</em> becomes a stored function field concatenating the <em>last
424419
name</em> and the <em>first name</em>. This avoids breaking compatibility with
425420
other modules.</p>
@@ -436,7 +431,7 @@ <h2><a class="toc-backref" href="#toc-entry-2">Usage</a></h2>
436431
contact).</p>
437432
</div>
438433
<div class="section" id="known-issues-roadmap">
439-
<h2><a class="toc-backref" href="#toc-entry-3">Known issues / Roadmap</a></h2>
434+
<h1><a class="toc-backref" href="#toc-entry-3">Known issues / Roadmap</a></h1>
440435
<p>Patterns for the inverse function are configurable only at system level.
441436
Maybe this configuration could depend on partner language, country or
442437
company, as discussed at <a class="reference external" href="https://github.com/OCA/partner-contact/issues/210">this OCA
@@ -445,17 +440,17 @@ <h2><a class="toc-backref" href="#toc-entry-3">Known issues / Roadmap</a></h2>
445440
level in firstname.mixin level, harmonizing different implementations.</p>
446441
</div>
447442
<div class="section" id="bug-tracker">
448-
<h2><a class="toc-backref" href="#toc-entry-4">Bug Tracker</a></h2>
443+
<h1><a class="toc-backref" href="#toc-entry-4">Bug Tracker</a></h1>
449444
<p>Bugs are tracked on <a class="reference external" href="https://github.com/OCA/partner-contact/issues">GitHub Issues</a>.
450445
In case of trouble, please check there if your issue has already been reported.
451446
If you spotted it first, help us to smash it by providing a detailed and welcomed
452447
<a class="reference external" href="https://github.com/OCA/partner-contact/issues/new?body=module:%20partner_firstname%0Aversion:%2018.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
453448
<p>Do not contact contributors directly about support or help with technical issues.</p>
454449
</div>
455450
<div class="section" id="credits">
456-
<h2><a class="toc-backref" href="#toc-entry-5">Credits</a></h2>
451+
<h1><a class="toc-backref" href="#toc-entry-5">Credits</a></h1>
457452
<div class="section" id="authors">
458-
<h3><a class="toc-backref" href="#toc-entry-6">Authors</a></h3>
453+
<h2><a class="toc-backref" href="#toc-entry-6">Authors</a></h2>
459454
<ul class="simple">
460455
<li>Camptocamp</li>
461456
<li>Grupo ESOC Ingeniería de Servicios</li>
@@ -467,7 +462,7 @@ <h3><a class="toc-backref" href="#toc-entry-6">Authors</a></h3>
467462
</ul>
468463
</div>
469464
<div class="section" id="contributors">
470-
<h3><a class="toc-backref" href="#toc-entry-7">Contributors</a></h3>
465+
<h2><a class="toc-backref" href="#toc-entry-7">Contributors</a></h2>
471466
<ul class="simple">
472467
<li>Nicolas Bessi &lt;<a class="reference external" href="mailto:nicolas.bessi&#64;camptocamp.com">nicolas.bessi&#64;camptocamp.com</a>&gt;</li>
473468
<li>Yannick Vaucher &lt;<a class="reference external" href="mailto:yannick.vaucher&#64;camptocamp.com">yannick.vaucher&#64;camptocamp.com</a>&gt;</li>
@@ -496,7 +491,7 @@ <h3><a class="toc-backref" href="#toc-entry-7">Contributors</a></h3>
496491
</ul>
497492
</div>
498493
<div class="section" id="maintainers">
499-
<h3><a class="toc-backref" href="#toc-entry-8">Maintainers</a></h3>
494+
<h2><a class="toc-backref" href="#toc-entry-8">Maintainers</a></h2>
500495
<p>This module is maintained by the OCA.</p>
501496
<a class="reference external image-reference" href="https://odoo-community.org">
502497
<img alt="Odoo Community Association" src="https://odoo-community.org/logo.png" />
@@ -511,6 +506,5 @@ <h3><a class="toc-backref" href="#toc-entry-8">Maintainers</a></h3>
511506
</div>
512507
</div>
513508
</div>
514-
</div>
515509
</body>
516510
</html>

partner_firstname/views/res_partner.xml

Lines changed: 25 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,22 @@
33
<field name="model">res.partner</field>
44
<field name="inherit_id" ref="base.view_partner_simple_form" />
55
<field name="arch" type="xml">
6-
<field name="name" position="after">
7-
<field name="is_individual" invisible="1" />
8-
</field>
96
<xpath expr="//field[@id='individual']" position="attributes">
10-
<attribute name="readonly">is_individual</attribute>
7+
<attribute name="invisible">is_company</attribute>
8+
<attribute name="readonly">not is_company</attribute>
9+
<attribute name="required">type == 'contact' and is_company</attribute>
10+
</xpath>
11+
<xpath expr="//field[@id='company']" position="attributes">
12+
<attribute name="invisible">is_company == False</attribute>
13+
<attribute name="readonly">not is_company</attribute>
14+
<attribute name="required">type == 'contact' and is_company</attribute>
1115
</xpath>
1216
<xpath expr="//h1//field[@id='company']/.." position="before">
13-
<group invisible="not is_individual">
17+
<group invisible="is_company">
1418
<field
15-
name="lastname"
16-
required="lastname_required"
1719
invisible="not form_has_lastname_first"
20+
name="lastname"
21+
required="form_has_lastname_first and lastname_required"
1822
/>
1923
<field name="firstname" required="firstname_required" />
2024
<field
@@ -30,18 +34,22 @@
3034
<field name="model">res.partner</field>
3135
<field name="inherit_id" ref="base.view_partner_form" />
3236
<field name="arch" type="xml">
33-
<field name="name" position="after">
34-
<field name="is_individual" invisible="1" />
35-
</field>
3637
<xpath expr="//field[@id='individual']" position="attributes">
37-
<attribute name="readonly">is_individual</attribute>
38+
<attribute name="invisible">is_company</attribute>
39+
<attribute name="readonly">not is_company</attribute>
40+
<attribute name="required">type == 'contact' and is_company</attribute>
41+
</xpath>
42+
<xpath expr="//field[@id='company']" position="attributes">
43+
<attribute name="invisible">not is_company</attribute>
44+
<attribute name="readonly">not is_company</attribute>
45+
<attribute name="required">type == 'contact' and is_company</attribute>
3846
</xpath>
3947
<xpath
4048
expr="//div[hasclass('oe_title')]//field[@id='company']/.."
4149
position="after"
4250
>
4351
<div class="oe_edit_only">
44-
<group invisible="not is_individual">
52+
<group invisible="is_company">
4553
<field
4654
invisible="not form_has_lastname_first"
4755
name="lastname"
@@ -56,20 +64,21 @@
5664
</group>
5765
</div>
5866
</xpath>
59-
67+
<!-- Modify inner contact form of child_ids -->
6068
<xpath
6169
expr="//field[@name='child_ids']/form//field[@name='name']"
6270
position="attributes"
6371
>
64-
<attribute name="invisible">is_individual</attribute>
72+
<attribute name="readonly">not is_company</attribute>
73+
<attribute name="required">is_company</attribute>
6574
</xpath>
66-
6775
<xpath
6876
expr="//field[@name='child_ids']/form//field[@name='name']"
6977
position="after"
7078
>
7179
<div class="oe_edit_only" colspan="2">
72-
<group invisible="not is_individual">
80+
<field name="is_company" invisible="True" />
81+
<group invisible="is_company">
7382
<field
7483
invisible="not form_has_lastname_first"
7584
name="lastname"

0 commit comments

Comments
 (0)