rename church events after update

This commit is contained in:
meichthys 2025-11-07 06:11:03 +00:00
parent c5de7e5995
commit 34359aa8ab

View File

@ -3,12 +3,28 @@
import frappe
from frappe.model.document import Document
from frappe.model.mapper import get_mapped_doc
class ChurchEvent(Document):
pass
def autoname(self):
name = self.get_name()
if not frappe.db.exists("Church Event", self.name):
self.name = name
return
else:
if self.name != self.get_name():
frappe.rename_doc("Church Event", self.name, name)
def get_name(self):
"""Constructs the document name"""
return f"{self.start_date} ({self.type}) - {self.event_name}"
def on_update(self):
# Rename document when updating
self.autoname()
@frappe.whitelist()
def apply_template(source_name):