Display family members on Family form.

This commit is contained in:
meichthys 2025-12-20 06:54:31 +00:00
parent 531c545d5f
commit 830334e3d7
6 changed files with 91 additions and 5 deletions

View File

@ -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",

View File

@ -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": []
}

View File

@ -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

View File

@ -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:

View File

@ -1,6 +1,6 @@
{
"charts": [],
"content": "[{\"id\":\"nnvMTG5Sl5\",\"type\":\"paragraph\",\"data\":{\"text\":\"<span class=\\\"h1\\\" style=\\\"font-weight: normal;\\\">\ud83d\udc65People&nbsp;Manual</span>\",\"col\":12}},{\"id\":\"B-CtTCmVDX\",\"type\":\"paragraph\",\"data\":{\"text\":\"<span style=\\\"font-weight: normal;\\\">The people module contains features relating to the people of the church (i.e. Members, Families, Leadership. etc).</span>\",\"col\":12}},{\"id\":\"Htx875Wd1w\",\"type\":\"paragraph\",\"data\":{\"text\":\"The <a href=\\\"http://development.localhost/app/people\\\">People workspace</a> 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\":\"<span class=\\\"h2\\\">\ud83d\udc64Person</span>\",\"col\":12}},{\"id\":\"RZThk3_x4O\",\"type\":\"paragraph\",\"data\":{\"text\":\"<a href=\\\"http://app/church-person\\\">Church people</a> include guests, members, leadership, and other people who interact or are associated with the church.\",\"col\":12}},{\"id\":\"UJEDTpYJIM\",\"type\":\"paragraph\",\"data\":{\"text\":\"When <a href=\\\"/app/church-person/new-church-person\\\">adding a person</a>, note the following:<br>- Church membership and baptism status can be indicated.<br>&nbsp; &nbsp; - If needed, additional <a href=\\\"/app/church-member-status\\\">member status types</a> can be created.<br>- If the person has any roles in the church, they should be indicated in the 'Church Roles' section.&nbsp;<br>&nbsp; &nbsp;- If a <a href=\\\"/app/church-role-type\\\">role type</a> does not exist, you can <a href=\\\"/app/church-role-type/new-church-role-type\\\">create new role types</a> as needed.<br>- Photos should be added for members. The photos will be used in a member directory in a future versions.<br>- Letters from this person can be added in the 'Contact' tab<br>- Family relationships can be defined in the 'Family' tab.<br>&nbsp; &nbsp; - When a spouse is added, the spouse's document will also be updated accordingly.<br>&nbsp; &nbsp; - Additional relationships can be defined in the 'Notable Relationships' section - these relationships are not auto-updated on the other person's document.<br>&nbsp; &nbsp; - 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\":\"<span class=\\\"h4\\\">Person Directory</span>\",\"col\":12}},{\"id\":\"aIL5EgTGiJ\",\"type\":\"paragraph\",\"data\":{\"text\":\"<span style=\\\"font-weight: normal;\\\">To generate a Church Directory:<br>1. Navigate to the <a href=\\\"/app/church-person\\\">church person list</a>.<br>2. (Optionally) Check the <i>Is Member </i>filter to only show members.<br>3. Select all the people by checking the top left checkbox in the list.<br>4. Click the <i>Actions </i>button and choose <i>Print</i>.<br>5. Select your print options and click <i>Print</i> to generate a member directory pdf file.<br>&nbsp; &nbsp; - Tip: To make each person page smaller when printing the pdf, you can use the <i>print multiple pages per sheet</i> option in your system print dialog (if your system supports this feature).</span>\",\"col\":12}},{\"id\":\"A37CU_rUFj\",\"type\":\"paragraph\",\"data\":{\"text\":\"<span class=\\\"h2\\\">\ud83d\udc68\u200d\ud83d\udc69\u200d\ud83d\udc67\u200d\ud83d\udc66Family</span>\",\"col\":12}},{\"id\":\"_wxytNqTX4\",\"type\":\"paragraph\",\"data\":{\"text\":\"<a href=\\\"/app/church-family\\\">Families</a> are groups of <a href=\\\"/app/church-person\\\">people</a> who are related.\",\"col\":12}},{\"id\":\"qQr_8PsoeH\",\"type\":\"paragraph\",\"data\":{\"text\":\"When <a href=\\\"/app/church-family/new-church-family\\\">adding a family</a>, note the following:<br>- After adding a family, you may want to link people to the family.<br>- Only one <a href=\\\"/app/church-person\\\">person</a> 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.<br>\",\"col\":12}}]",
"content": "[{\"id\":\"nnvMTG5Sl5\",\"type\":\"paragraph\",\"data\":{\"text\":\"<span class=\\\"h1\\\" style=\\\"font-weight: normal;\\\">\ud83d\udc65People&nbsp;Manual</span>\",\"col\":12}},{\"id\":\"B-CtTCmVDX\",\"type\":\"paragraph\",\"data\":{\"text\":\"<span style=\\\"font-weight: normal;\\\">The people module contains features relating to the people of the church (i.e. Members, Families, Leadership. etc).</span>\",\"col\":12}},{\"id\":\"Htx875Wd1w\",\"type\":\"paragraph\",\"data\":{\"text\":\"The <a href=\\\"http://development.localhost/app/people\\\">People workspace</a> 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\":\"<span class=\\\"h2\\\">\ud83d\udc64Person</span>\",\"col\":12}},{\"id\":\"RZThk3_x4O\",\"type\":\"paragraph\",\"data\":{\"text\":\"<a href=\\\"http://app/church-person\\\">Church people</a> include guests, members, leadership, and other people who interact or are associated with the church.\",\"col\":12}},{\"id\":\"UJEDTpYJIM\",\"type\":\"paragraph\",\"data\":{\"text\":\"When <a href=\\\"/app/church-person/new-church-person\\\">adding a person</a>, note the following:<br>- Church membership and baptism status can be indicated.<br>&nbsp; &nbsp; - If needed, additional <a href=\\\"/app/church-member-status\\\">member status types</a> can be created.<br>- If the person has any roles in the church, they should be indicated in the 'Church Roles' section.&nbsp;<br>&nbsp; &nbsp;- If a <a href=\\\"/app/church-role-type\\\">role type</a> does not exist, you can <a href=\\\"/app/church-role-type/new-church-role-type\\\">create new role types</a> as needed.<br>- Photos should be added for members. The photos will be used in a member directory in a future versions.<br>- Letters from this person can be added in the 'Contact' tab<br>- If a family has been selected, the person will be displayed in the \\\"Family Members\\\" section on the `Church Family` form.<br>- Family relationships can be defined in the 'Family' tab.<br>&nbsp; &nbsp; - When a spouse is added, the spouse's document will also be updated accordingly.<br>&nbsp; &nbsp; - Additional relationships can be defined in the 'Notable Relationships' section - these relationships are not auto-updated on the other person's document.<br>&nbsp; &nbsp; - 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\":\"<span class=\\\"h4\\\">Person/Member Directory</span>\",\"col\":12}},{\"id\":\"aIL5EgTGiJ\",\"type\":\"paragraph\",\"data\":{\"text\":\"<span style=\\\"font-weight: normal;\\\">To generate a Church Directory:<br>1. Navigate to the <a href=\\\"/app/church-person\\\">church person list</a>.<br>2. (Optionally) Check the <i>Is Member </i>filter to only show members.<br>3. Select all the people by checking the top left checkbox in the list.<br>4. Click the <i>Actions </i>button and choose <i>Print</i>.<br>5. Select your print options and click <i>Print</i> to generate a member directory pdf file.<br>&nbsp; &nbsp; - Tip: To make each person page smaller when printing the pdf, you can use the <i>print multiple pages per sheet</i> option in your system print dialog (if your system supports this feature).</span>\",\"col\":12}},{\"id\":\"A37CU_rUFj\",\"type\":\"paragraph\",\"data\":{\"text\":\"<span class=\\\"h2\\\">\ud83d\udc68\u200d\ud83d\udc69\u200d\ud83d\udc67\u200d\ud83d\udc66Family</span>\",\"col\":12}},{\"id\":\"_wxytNqTX4\",\"type\":\"paragraph\",\"data\":{\"text\":\"<a href=\\\"/app/church-family\\\">Families</a> are groups of <a href=\\\"/app/church-person\\\">people</a> who are related.\",\"col\":12}},{\"id\":\"qQr_8PsoeH\",\"type\":\"paragraph\",\"data\":{\"text\":\"When <a href=\\\"/app/church-family/new-church-family\\\">adding a family</a>, note the following:<br>- 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.<br>- Only one <a href=\\\"/app/church-person\\\">person</a> 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.<br>\",\"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",