Skip to content

Commit

Permalink
modificado: atvirtual/atvirtual/doctype/participant/participant.py
Browse files Browse the repository at this point in the history
  • Loading branch information
pibico committed Feb 20, 2021
1 parent 0953281 commit 062c096
Showing 1 changed file with 22 additions and 2 deletions.
24 changes: 22 additions & 2 deletions atvirtual/atvirtual/doctype/participant/participant.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,28 @@
# For license information, please see license.txt

from __future__ import unicode_literals
# import frappe
import frappe
from frappe.model.document import Document
from frappe import _
from frappe.desk.form.linked_with import get_linked_doctypes

class Participant(Document):
pass
def validate(self):
self.title = " ".join(filter(None, [self.first_name, self.middle_name, self.last_name]))

if frappe.get_value("Participant", self.name, "title") != self.title:
self.update_participant_name_in_linked_doctype()

def update_participant_name_in_linked_doctype(self):
linked_doctypes = get_linked_doctypes("Participant")
for d in linked_doctypes:
meta = frappe.get_meta(d)
if not meta.issingle:
if "participant_name" in [f.fieldname for f in meta.fields]:
frappe.db.sql("""UPDATE `tab{0}` set participant_name = %s where {1} = %s"""
.format(d, linked_doctypes[d]["fieldname"][0]),(self.title, self.name))

if "child_doctype" in linked_doctypes[d].keys() and "participant_name" in \
[f.fieldname for f in frappe.get_meta(linked_doctypes[d]["child_doctype"]).fields]:
frappe.db.sql("""UPDATE `tab{0}` set participant_name = %s where {1} = %s"""
.format(linked_doctypes[d]["child_doctype"], linked_doctypes[d]["fieldname"][0]),(self.title, self.name))

0 comments on commit 062c096

Please sign in to comment.