Skip to content

Commit 542893b

Browse files
[NEW] spp_registry_name_suffix
1 parent aef0602 commit 542893b

File tree

15 files changed

+982
-0
lines changed

15 files changed

+982
-0
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
from . import models
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# Part of OpenSPP. See LICENSE file for full copyright and licensing details.
2+
{
3+
"name": "OpenSPP Registry Name Suffix",
4+
"summary": "Adds a configurable suffix field (Jr., Sr., III, etc.) to Individual registrant names in OpenSPP.",
5+
"category": "OpenSPP",
6+
"version": "17.0.1.4.0",
7+
"sequence": 1,
8+
"author": "OpenSPP.org",
9+
"website": "https://github.com/OpenSPP/openspp-modules",
10+
"license": "LGPL-3",
11+
"development_status": "Beta",
12+
"maintainers": ["jeremi", "gonzalesedwin1123"],
13+
"depends": [
14+
"spp_registrant_import",
15+
"g2p_registry_individual",
16+
],
17+
"data": [
18+
"security/ir.model.access.csv",
19+
"views/name_suffix_views.xml",
20+
"views/res_partner_views.xml",
21+
"data/name_suffix_data.xml",
22+
],
23+
"assets": {},
24+
"demo": [],
25+
"images": [],
26+
"application": False,
27+
"installable": True,
28+
"auto_install": False,
29+
}
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
<?xml version="1.0" encoding="utf-8" ?>
2+
<odoo noupdate="1">
3+
4+
<!-- Generational Suffixes -->
5+
<record id="suffix_jr" model="spp.name.suffix">
6+
<field name="name">Jr.</field>
7+
<field name="code">JR</field>
8+
<field name="sequence">10</field>
9+
<field name="description">Junior - typically used for a son named after his father</field>
10+
</record>
11+
12+
<record id="suffix_sr" model="spp.name.suffix">
13+
<field name="name">Sr.</field>
14+
<field name="code">SR</field>
15+
<field name="sequence">20</field>
16+
<field name="description">Senior - typically used for a father when a son has the same name</field>
17+
</record>
18+
19+
<record id="suffix_i" model="spp.name.suffix">
20+
<field name="name">I</field>
21+
<field name="code">I</field>
22+
<field name="sequence">30</field>
23+
<field name="description">The First</field>
24+
</record>
25+
26+
<record id="suffix_ii" model="spp.name.suffix">
27+
<field name="name">II</field>
28+
<field name="code">II</field>
29+
<field name="sequence">40</field>
30+
<field name="description">The Second</field>
31+
</record>
32+
33+
<record id="suffix_iii" model="spp.name.suffix">
34+
<field name="name">III</field>
35+
<field name="code">III</field>
36+
<field name="sequence">50</field>
37+
<field name="description">The Third</field>
38+
</record>
39+
40+
<record id="suffix_iv" model="spp.name.suffix">
41+
<field name="name">IV</field>
42+
<field name="code">IV</field>
43+
<field name="sequence">60</field>
44+
<field name="description">The Fourth</field>
45+
</record>
46+
47+
<record id="suffix_v" model="spp.name.suffix">
48+
<field name="name">V</field>
49+
<field name="code">V</field>
50+
<field name="sequence">70</field>
51+
<field name="description">The Fifth</field>
52+
</record>
53+
54+
<!-- Academic/Professional Suffixes -->
55+
<record id="suffix_phd" model="spp.name.suffix">
56+
<field name="name">PhD</field>
57+
<field name="code">PHD</field>
58+
<field name="sequence">100</field>
59+
<field name="description">Doctor of Philosophy</field>
60+
</record>
61+
62+
<record id="suffix_md" model="spp.name.suffix">
63+
<field name="name">MD</field>
64+
<field name="code">MD</field>
65+
<field name="sequence">110</field>
66+
<field name="description">Doctor of Medicine</field>
67+
</record>
68+
69+
<record id="suffix_esq" model="spp.name.suffix">
70+
<field name="name">Esq.</field>
71+
<field name="code">ESQ</field>
72+
<field name="sequence">120</field>
73+
<field name="description">Esquire - typically used for attorneys</field>
74+
</record>
75+
76+
</odoo>
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
from . import name_suffix
2+
from . import res_partner
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
from odoo import fields, models
2+
3+
4+
class SPPNameSuffix(models.Model):
5+
_name = "spp.name.suffix"
6+
_description = "Name Suffix"
7+
_order = "sequence, name"
8+
9+
name = fields.Char(
10+
string="Suffix",
11+
required=True,
12+
help="The suffix value (e.g., Jr., Sr., III, PhD)",
13+
)
14+
code = fields.Char(
15+
string="Code",
16+
required=True,
17+
help="Short code for the suffix",
18+
)
19+
sequence = fields.Integer(
20+
string="Sequence",
21+
default=10,
22+
help="Used to order suffixes in dropdown lists",
23+
)
24+
active = fields.Boolean(
25+
string="Active",
26+
default=True,
27+
help="If unchecked, the suffix will not be available for selection",
28+
)
29+
description = fields.Text(
30+
string="Description",
31+
help="Additional description or usage notes for this suffix",
32+
)
33+
34+
_sql_constraints = [
35+
(
36+
"name_uniq",
37+
"unique(name)",
38+
"Suffix name must be unique!",
39+
),
40+
(
41+
"code_uniq",
42+
"unique(code)",
43+
"Suffix code must be unique!",
44+
),
45+
]
46+
47+
def name_get(self):
48+
"""Display suffix name with code if different."""
49+
result = []
50+
for record in self:
51+
if record.code and record.code != record.name:
52+
name = f"{record.name} ({record.code})"
53+
else:
54+
name = record.name
55+
result.append((record.id, name))
56+
return result
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
from odoo import api, fields, models
2+
3+
4+
class ResPartner(models.Model):
5+
_inherit = "res.partner"
6+
7+
suffix_id = fields.Many2one(
8+
comodel_name="spp.name.suffix",
9+
string="Suffix",
10+
ondelete="restrict",
11+
help="Name suffix such as Jr., Sr., III, IV, PhD, MD, etc.",
12+
)
13+
14+
@api.depends(
15+
"is_registrant",
16+
"is_group",
17+
"family_name",
18+
"given_name",
19+
"addl_name",
20+
"suffix_id",
21+
)
22+
def _compute_name(self):
23+
"""Extend name computation to include suffix for individuals."""
24+
super()._compute_name()
25+
for rec in self:
26+
if not rec.is_registrant or rec.is_group:
27+
continue
28+
if rec.suffix_id:
29+
rec.name = f"{rec.name}, {rec.suffix_id.name.upper()}"
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[build-system]
2+
requires = ["whool"]
3+
build-backend = "whool.buildapi"
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
# OpenSPP Registry Name Suffix
2+
3+
The `spp_registry_name_suffix` module adds a configurable suffix field to Individual registrant names in OpenSPP, enabling proper recording of name suffixes such as Jr., Sr., III, IV, PhD, MD, etc.
4+
5+
## Purpose
6+
7+
This module enhances individual registrant data by:
8+
9+
* **Providing configurable suffixes**: Administrators can manage available suffixes through the Registry Configuration menu.
10+
* **Adding suffix support**: Record name suffixes using a standardized Many2one field reference.
11+
* **Extending name generation**: Automatically includes the suffix in the computed full name.
12+
* **Maintaining data integrity**: The suffix is stored as a reference to a configurable suffix record.
13+
14+
## Features
15+
16+
### Suffix Configuration
17+
A new "Name Suffixes" menu is available under Registry > Configuration, allowing administrators to:
18+
- Create, edit, and archive name suffixes
19+
- Define suffix codes for data integration
20+
- Set display order using sequence numbers
21+
- Add descriptions for suffix usage guidance
22+
23+
### Pre-configured Suffixes
24+
The module comes with commonly used suffixes:
25+
- **Generational**: Jr., Sr., I, II, III, IV, V
26+
- **Academic/Professional**: PhD, MD, Esq.
27+
28+
### Individual Registrant Integration
29+
The suffix field appears on the Individual registrant form after the "Additional Name" field. It uses a dropdown selection with the following features:
30+
- Quick search by suffix name or code
31+
- No inline creation (to maintain data quality)
32+
- Optional display in the registrant list view
33+
34+
### Automatic Name Generation
35+
The suffix is automatically appended to the registrant's computed name in the format:
36+
`FAMILY_NAME, GIVEN_NAME, ADDL_NAME, SUFFIX`
37+
38+
For example: "SMITH, JOHN, MICHAEL, JR."
39+
40+
## Dependencies
41+
42+
This module depends on:
43+
- **spp_registrant_import**: Provides the base name computation logic for registrants.
44+
- **g2p_registry_individual**: Provides the individual registrant views and model.
45+
46+
## Configuration
47+
48+
1. Navigate to Registry > Configuration > Name Suffixes
49+
2. Create additional suffixes as needed for your implementation
50+
3. Set the sequence to control display order in dropdowns
51+
52+
## Usage
53+
54+
1. Navigate to an Individual registrant form
55+
2. Select a suffix from the "Suffix" dropdown field
56+
3. The full name will automatically update to include the suffix
57+
58+
## References
59+
60+
- OpenG2P Registry Individual: https://github.com/OpenSPP/openg2p-registry/tree/17.0-develop-openspp/g2p_registry_individual
61+
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
2+
3+
spp_name_suffix_registrar,SPP Name Suffix Registrar Access,spp_registry_name_suffix.model_spp_name_suffix,g2p_registry_base.group_g2p_registrar,1,1,1,1
4+
spp_name_suffix_admin,SPP Name Suffix Admin Access,spp_registry_name_suffix.model_spp_name_suffix,g2p_registry_base.group_g2p_admin,1,1,1,1
15.1 KB
Loading

0 commit comments

Comments
 (0)