From 830334e3d7906bb3d0943b357128d8f501eb2b7c Mon Sep 17 00:00:00 2001 From: meichthys Date: Sat, 20 Dec 2025 06:54:31 +0000 Subject: [PATCH] Display family members on Family form. --- .../doctype/church_family/church_family.json | 14 +++++-- .../doctype/church_family_members/__init__.py | 0 .../church_family_members.json | 38 +++++++++++++++++++ .../church_family_members.py | 9 +++++ .../doctype/church_person/church_person.py | 31 +++++++++++++++ .../manual:_people/manual:_people.json | 4 +- 6 files changed, 91 insertions(+), 5 deletions(-) create mode 100644 church/church_people/doctype/church_family_members/__init__.py create mode 100644 church/church_people/doctype/church_family_members/church_family_members.json create mode 100644 church/church_people/doctype/church_family_members/church_family_members.py diff --git a/church/church_people/doctype/church_family/church_family.json b/church/church_people/doctype/church_family/church_family.json index 2621769..958c9dc 100644 --- a/church/church_people/doctype/church_family/church_family.json +++ b/church/church_people/doctype/church_family/church_family.json @@ -11,9 +11,10 @@ "section_break_acrr", "family_name", "head_of_household", - "column_break_pmch", "home_address", - "photo" + "photo", + "column_break_pmch", + "members" ], "fields": [ { @@ -55,6 +56,13 @@ { "fieldname": "section_break_acrr", "fieldtype": "Section Break" + }, + { + "fieldname": "members", + "fieldtype": "Table", + "label": "Family Members", + "options": "Church Family Members", + "read_only": 1 } ], "grid_page_length": 50, @@ -70,7 +78,7 @@ "link_fieldname": "recipient" } ], - "modified": "2025-11-15 22:55:14.237301", + "modified": "2025-12-20 01:46:01.200249", "modified_by": "Administrator", "module": "Church People", "name": "Church Family", diff --git a/church/church_people/doctype/church_family_members/__init__.py b/church/church_people/doctype/church_family_members/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/church/church_people/doctype/church_family_members/church_family_members.json b/church/church_people/doctype/church_family_members/church_family_members.json new file mode 100644 index 0000000..40d3c4a --- /dev/null +++ b/church/church_people/doctype/church_family_members/church_family_members.json @@ -0,0 +1,38 @@ +{ + "actions": [], + "allow_rename": 1, + "creation": "2025-12-20 00:48:57.168497", + "description": "People who are part of a `Church Family`", + "doctype": "DocType", + "documentation": "/app/manual%3A-people#family", + "engine": "InnoDB", + "field_order": [ + "member" + ], + "fields": [ + { + "fieldname": "member", + "fieldtype": "Link", + "in_list_view": 1, + "in_preview": 1, + "label": "Family Member", + "options": "Church Person", + "read_only": 1, + "reqd": 1 + } + ], + "grid_page_length": 50, + "index_web_pages_for_search": 1, + "istable": 1, + "links": [], + "modified": "2025-12-20 01:48:38.401634", + "modified_by": "Administrator", + "module": "Church People", + "name": "Church Family Members", + "owner": "Administrator", + "permissions": [], + "row_format": "Dynamic", + "sort_field": "modified", + "sort_order": "DESC", + "states": [] +} \ No newline at end of file diff --git a/church/church_people/doctype/church_family_members/church_family_members.py b/church/church_people/doctype/church_family_members/church_family_members.py new file mode 100644 index 0000000..d16651c --- /dev/null +++ b/church/church_people/doctype/church_family_members/church_family_members.py @@ -0,0 +1,9 @@ +# Copyright (c) 2025, meichthys and contributors +# For license information, please see license.txt + +# import frappe +from frappe.model.document import Document + + +class ChurchFamilyMembers(Document): + pass diff --git a/church/church_people/doctype/church_person/church_person.py b/church/church_people/doctype/church_person/church_person.py index d770497..5bf5963 100644 --- a/church/church_people/doctype/church_person/church_person.py +++ b/church/church_people/doctype/church_person/church_person.py @@ -8,11 +8,42 @@ from frappe.model.document import Document class ChurchPerson(Document): + def on_update(self): + # Update Family Member list in Church Family + if self.family: + family = frappe.get_doc("Church Family", self.family) + found = False + for member in family.members: + if member.member == self.name: + found = True + break + if not found: + family.append("members", {"member": self.name}) + family.save() + # Remove person from Church Family if family is removed + if not self.family and hasattr(self.get_doc_before_save(), "family"): + family = frappe.get_doc("Church Family", self.get_doc_before_save().family) + for member in family.members: + if member.member == self.name: + family.remove(member) + break + family.save() + def before_save(self): # We set this here since virtual fields do not work with # View Settings -> Title Field as of 2025-08-26 self.full_name = f"{self.first_name}" + ((" " + self.last_name) if self.last_name else "") + def before_delete(self): + # Remove person from Church Family + if self.family: + family = frappe.get_doc("Church Family", self.family) + for member in family.members: + if member.name == self.name: + family.remove(member) + break + family.save() + def validate(self): # Remove head of household status when family is removed if not self.family and self.is_head_of_household: diff --git a/church/church_people/workspace/manual:_people/manual:_people.json b/church/church_people/workspace/manual:_people/manual:_people.json index eec731c..abaaeb9 100644 --- a/church/church_people/workspace/manual:_people/manual:_people.json +++ b/church/church_people/workspace/manual:_people/manual:_people.json @@ -1,6 +1,6 @@ { "charts": [], - "content": "[{\"id\":\"nnvMTG5Sl5\",\"type\":\"paragraph\",\"data\":{\"text\":\"\ud83d\udc65People Manual\",\"col\":12}},{\"id\":\"B-CtTCmVDX\",\"type\":\"paragraph\",\"data\":{\"text\":\"The people module contains features relating to the people of the church (i.e. Members, Families, Leadership. etc).\",\"col\":12}},{\"id\":\"Htx875Wd1w\",\"type\":\"paragraph\",\"data\":{\"text\":\"The People workspace contains number cards and graphs indicating the current count of people/families/members. there are also links to various reports (Birthdays, Roles, Letters, etc).\",\"col\":12}},{\"id\":\"qI9ZNpJJX4\",\"type\":\"paragraph\",\"data\":{\"text\":\"\ud83d\udc64Person\",\"col\":12}},{\"id\":\"RZThk3_x4O\",\"type\":\"paragraph\",\"data\":{\"text\":\"Church people include guests, members, leadership, and other people who interact or are associated with the church.\",\"col\":12}},{\"id\":\"UJEDTpYJIM\",\"type\":\"paragraph\",\"data\":{\"text\":\"When adding a person, note the following:
- Church membership and baptism status can be indicated.
    - If needed, additional member status types can be created.
- If the person has any roles in the church, they should be indicated in the 'Church Roles' section. 
   - If a role type does not exist, you can create new role types as needed.
- Photos should be added for members. The photos will be used in a member directory in a future versions.
- Letters from this person can be added in the 'Contact' tab
- Family relationships can be defined in the 'Family' tab.
    - When a spouse is added, the spouse's document will also be updated accordingly.
    - Additional relationships can be defined in the 'Notable Relationships' section - these relationships are not auto-updated on the other person's document.
    - A Family can be automatically created from a person by clicking the 'New Family From Person' button. This requires a 'Last Name' to be set, and will set the person as the Family's head-of-household.\",\"col\":12}},{\"id\":\"0a0Yfbfao3\",\"type\":\"paragraph\",\"data\":{\"text\":\"Person Directory\",\"col\":12}},{\"id\":\"aIL5EgTGiJ\",\"type\":\"paragraph\",\"data\":{\"text\":\"To generate a Church Directory:
1. Navigate to the church person list.
2. (Optionally) Check the Is Member filter to only show members.
3. Select all the people by checking the top left checkbox in the list.
4. Click the Actions button and choose Print.
5. Select your print options and click Print to generate a member directory pdf file.
    - Tip: To make each person page smaller when printing the pdf, you can use the print multiple pages per sheet option in your system print dialog (if your system supports this feature).
\",\"col\":12}},{\"id\":\"A37CU_rUFj\",\"type\":\"paragraph\",\"data\":{\"text\":\"\ud83d\udc68\u200d\ud83d\udc69\u200d\ud83d\udc67\u200d\ud83d\udc66Family\",\"col\":12}},{\"id\":\"_wxytNqTX4\",\"type\":\"paragraph\",\"data\":{\"text\":\"Families are groups of people who are related.\",\"col\":12}},{\"id\":\"qQr_8PsoeH\",\"type\":\"paragraph\",\"data\":{\"text\":\"When adding a family, note the following:
- After adding a family, you may want to link people to the family.
- Only one person can be set as the head of household. To set the head-of-household, go to the person's document and check 'Is Head of Household' on the 'Family' tab.
\",\"col\":12}}]", + "content": "[{\"id\":\"nnvMTG5Sl5\",\"type\":\"paragraph\",\"data\":{\"text\":\"\ud83d\udc65People Manual\",\"col\":12}},{\"id\":\"B-CtTCmVDX\",\"type\":\"paragraph\",\"data\":{\"text\":\"The people module contains features relating to the people of the church (i.e. Members, Families, Leadership. etc).\",\"col\":12}},{\"id\":\"Htx875Wd1w\",\"type\":\"paragraph\",\"data\":{\"text\":\"The People workspace contains number cards and graphs indicating the current count of people/families/members. there are also links to various reports (Birthdays, Roles, Letters, etc).\",\"col\":12}},{\"id\":\"qI9ZNpJJX4\",\"type\":\"paragraph\",\"data\":{\"text\":\"\ud83d\udc64Person\",\"col\":12}},{\"id\":\"RZThk3_x4O\",\"type\":\"paragraph\",\"data\":{\"text\":\"Church people include guests, members, leadership, and other people who interact or are associated with the church.\",\"col\":12}},{\"id\":\"UJEDTpYJIM\",\"type\":\"paragraph\",\"data\":{\"text\":\"When adding a person, note the following:
- Church membership and baptism status can be indicated.
    - If needed, additional member status types can be created.
- If the person has any roles in the church, they should be indicated in the 'Church Roles' section. 
   - If a role type does not exist, you can create new role types as needed.
- Photos should be added for members. The photos will be used in a member directory in a future versions.
- Letters from this person can be added in the 'Contact' tab
- If a family has been selected, the person will be displayed in the \\\"Family Members\\\" section on the `Church Family` form.
- Family relationships can be defined in the 'Family' tab.
    - When a spouse is added, the spouse's document will also be updated accordingly.
    - Additional relationships can be defined in the 'Notable Relationships' section - these relationships are not auto-updated on the other person's document.
    - A Family can be automatically created from a person by clicking the 'New Family From Person' button. This requires a 'Last Name' to be set, and will set the person as the Family's head-of-household.\",\"col\":12}},{\"id\":\"0a0Yfbfao3\",\"type\":\"paragraph\",\"data\":{\"text\":\"Person/Member Directory\",\"col\":12}},{\"id\":\"aIL5EgTGiJ\",\"type\":\"paragraph\",\"data\":{\"text\":\"To generate a Church Directory:
1. Navigate to the church person list.
2. (Optionally) Check the Is Member filter to only show members.
3. Select all the people by checking the top left checkbox in the list.
4. Click the Actions button and choose Print.
5. Select your print options and click Print to generate a member directory pdf file.
    - Tip: To make each person page smaller when printing the pdf, you can use the print multiple pages per sheet option in your system print dialog (if your system supports this feature).
\",\"col\":12}},{\"id\":\"A37CU_rUFj\",\"type\":\"paragraph\",\"data\":{\"text\":\"\ud83d\udc68\u200d\ud83d\udc69\u200d\ud83d\udc67\u200d\ud83d\udc66Family\",\"col\":12}},{\"id\":\"_wxytNqTX4\",\"type\":\"paragraph\",\"data\":{\"text\":\"Families are groups of people who are related.\",\"col\":12}},{\"id\":\"qQr_8PsoeH\",\"type\":\"paragraph\",\"data\":{\"text\":\"When adding a family, note the following:
- After adding a family, you may want to link people to the family. When a person is linked to a family, that person will be displayed in the \\\"Family Members\\\" list.
- Only one person can be set as the head of household. To set the head-of-household, go to the person's document and check 'Is Head of Household' on the 'Family' tab.
\",\"col\":12}}]", "creation": "2025-10-26 22:59:15.251142", "custom_blocks": [], "docstatus": 0, @@ -13,7 +13,7 @@ "is_hidden": 0, "label": "Manual: People", "links": [], - "modified": "2025-11-10 00:37:02.650282", + "modified": "2025-12-20 01:52:41.918887", "modified_by": "Administrator", "module": "Church People", "name": "Manual: People",