Skip to content

Commit 781c66f

Browse files
committed
[ADD] partner_lastname_uppercase
1 parent 05d5a23 commit 781c66f

File tree

14 files changed

+712
-0
lines changed

14 files changed

+712
-0
lines changed

partner_lastname_uppercase/README.rst

+102
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
===========================
2+
Partner last name uppercase
3+
===========================
4+
5+
..
6+
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
7+
!! This file is generated by oca-gen-addon-readme !!
8+
!! changes will be overwritten. !!
9+
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
10+
!! source digest: sha256:b30b0374ba032241d8111edb60ee7f23590c842bf9a13b4c1595456b4006831f
11+
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
12+
13+
.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
14+
:target: https://odoo-community.org/page/development-status
15+
:alt: Beta
16+
.. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png
17+
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
18+
:alt: License: AGPL-3
19+
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fpartner--contact-lightgray.png?logo=github
20+
:target: https://github.com/OCA/partner-contact/tree/16.0/partner_lastname_uppercase
21+
:alt: OCA/partner-contact
22+
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
23+
:target: https://translation.odoo-community.org/projects/partner-contact-16-0/partner-contact-16-0-partner_lastname_uppercase
24+
:alt: Translate me on Weblate
25+
.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png
26+
:target: https://runboat.odoo-community.org/builds?repo=OCA/partner-contact&target_branch=16.0
27+
:alt: Try me on Runboat
28+
29+
|badge1| |badge2| |badge3| |badge4| |badge5|
30+
31+
This module uppercases last names on create and write.
32+
33+
This module uses python `upper` function. This function uses the default
34+
unicode case folding*. This works for many languages, but not for all, like
35+
turkish where ı/I i/İ pairs work differently (see cpython issue
36+
`17252 <https://bugs.python.org/issue17252>`_).
37+
38+
\* The uppercasing algorithm used is described in section 3.13
39+
‘Default Case Folding’ of the
40+
`Unicode Standard <https://www.unicode.org/versions/Unicode15.0.0/ch03.pdf>`_.
41+
42+
**Table of contents**
43+
44+
.. contents::
45+
:local:
46+
47+
Usage
48+
=====
49+
50+
A server action (Uppercase all lastnames) is provided to initialize the data.
51+
To launch it :
52+
53+
- activate debug mode
54+
- find the action in Technical > Server Actions
55+
- click "add contextual action"
56+
- on any partner, from the action menu, run "Uppercase all lastnames"
57+
- return to the server action
58+
- click "remove the contextual action"
59+
60+
Note : this operation is not reversible.
61+
62+
Bug Tracker
63+
===========
64+
65+
Bugs are tracked on `GitHub Issues <https://github.com/OCA/partner-contact/issues>`_.
66+
In case of trouble, please check there if your issue has already been reported.
67+
If you spotted it first, help us to smash it by providing a detailed and welcomed
68+
`feedback <https://github.com/OCA/partner-contact/issues/new?body=module:%20partner_lastname_uppercase%0Aversion:%2016.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
69+
70+
Do not contact contributors directly about support or help with technical issues.
71+
72+
Credits
73+
=======
74+
75+
Authors
76+
~~~~~~~
77+
78+
* Coop IT Easy SC
79+
80+
Contributors
81+
~~~~~~~~~~~~
82+
83+
* `Coop IT Easy SC <https://coopiteasy.be>`_:
84+
85+
* Robin Keunen
86+
87+
Maintainers
88+
~~~~~~~~~~~
89+
90+
This module is maintained by the OCA.
91+
92+
.. image:: https://odoo-community.org/logo.png
93+
:alt: Odoo Community Association
94+
:target: https://odoo-community.org
95+
96+
OCA, or the Odoo Community Association, is a nonprofit organization whose
97+
mission is to support the collaborative development of Odoo features and
98+
promote its widespread use.
99+
100+
This module is part of the `OCA/partner-contact <https://github.com/OCA/partner-contact/tree/16.0/partner_lastname_uppercase>`_ project on GitHub.
101+
102+
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
from . import models
+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# Copyright 2023 Coop IT Easy SC
2+
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
3+
4+
{
5+
"name": "Partner last name uppercase",
6+
"summary": "Uppercases the the last names of partners",
7+
"version": "16.0.1.0.1",
8+
"author": "Coop IT Easy SC, Odoo Community Association (OCA)",
9+
"license": "AGPL-3",
10+
"maintainer": "Coop IT Easy SC",
11+
"category": "Extra Tools",
12+
"website": "https://github.com/OCA/partner-contact",
13+
"depends": ["partner_firstname"],
14+
"data": [
15+
"data/actions.xml",
16+
],
17+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<?xml version="1.0" encoding="utf-8" ?>
2+
<odoo>
3+
<record id="res_partner_lastname_uppercase_action" model="ir.actions.server">
4+
<field name="name">Uppercase all lastnames - not reversible</field>
5+
<field name="model_id" ref="base.model_res_partner" />
6+
<field name="state">code</field>
7+
<field name="code">model.uppercase_all_lastnames()</field>
8+
</record>
9+
</odoo>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
from . import res_partner
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
# Copyright 2023 Coop IT Easy SC
2+
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
3+
4+
from odoo import api, models
5+
6+
7+
class ResPartner(models.Model):
8+
_inherit = "res.partner"
9+
10+
@api.model
11+
def uppercase_all_lastnames(self):
12+
individuals = self.search(
13+
[
14+
("is_company", "=", False),
15+
("lastname", "!=", False),
16+
]
17+
)
18+
for partner in individuals:
19+
partner.lastname = partner.lastname.upper()
20+
21+
@api.model_create_multi
22+
def create(self, vals_list):
23+
for vals in vals_list:
24+
is_company = vals.get("is_company", False)
25+
lastname = vals.get("lastname", False)
26+
if lastname and not is_company:
27+
vals["lastname"] = lastname.upper()
28+
return super().create(vals_list)
29+
30+
def write(self, vals):
31+
res = super().write(vals)
32+
# uppercase is done after the write to exclude companies
33+
if "lastname" in vals or "is_company" in vals:
34+
individuals = self.filtered(lambda rp: rp.lastname and not rp.is_company)
35+
# looping in case only is_company is in vals (set to false)
36+
# in that case, uppercase each lastname
37+
for partner in individuals:
38+
super(ResPartner, partner).write({"lastname": partner.lastname.upper()})
39+
return res
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
* `Coop IT Easy SC <https://coopiteasy.be>`_:
2+
3+
* Robin Keunen
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
This module uppercases last names on create and write.
2+
3+
This module uses python `upper` function. This function uses the default
4+
unicode case folding*. This works for many languages, but not for all, like
5+
turkish where ı/I i/İ pairs work differently (see cpython issue
6+
`17252 <https://bugs.python.org/issue17252>`_).
7+
8+
\* The uppercasing algorithm used is described in section 3.13
9+
‘Default Case Folding’ of the
10+
`Unicode Standard <https://www.unicode.org/versions/Unicode15.0.0/ch03.pdf>`_.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
A server action (Uppercase all lastnames) is provided to initialize the data.
2+
To launch it :
3+
4+
- activate debug mode
5+
- find the action in Technical > Server Actions
6+
- click "add contextual action"
7+
- on any partner, from the action menu, run "Uppercase all lastnames"
8+
- return to the server action
9+
- click "remove the contextual action"
10+
11+
Note : this operation is not reversible.

0 commit comments

Comments
 (0)