style: format code with black

This commit is contained in:
Ankush Menat
2022-03-28 18:52:46 +05:30
parent 21e00da3d6
commit 494bd9ef78
1395 changed files with 91704 additions and 62532 deletions

View File

@@ -9,12 +9,16 @@ def update_lead_phone_numbers(contact, method):
if len(contact.phone_nos) > 1:
# get the default phone number
primary_phones = [phone_doc.phone for phone_doc in contact.phone_nos if phone_doc.is_primary_phone]
primary_phones = [
phone_doc.phone for phone_doc in contact.phone_nos if phone_doc.is_primary_phone
]
if primary_phones:
phone = primary_phones[0]
# get the default mobile number
primary_mobile_nos = [phone_doc.phone for phone_doc in contact.phone_nos if phone_doc.is_primary_mobile_no]
primary_mobile_nos = [
phone_doc.phone for phone_doc in contact.phone_nos if phone_doc.is_primary_mobile_no
]
if primary_mobile_nos:
mobile_no = primary_mobile_nos[0]
@@ -22,15 +26,21 @@ def update_lead_phone_numbers(contact, method):
lead.db_set("phone", phone)
lead.db_set("mobile_no", mobile_no)
def copy_comments(doctype, docname, doc):
comments = frappe.db.get_values("Comment", filters={"reference_doctype": doctype, "reference_name": docname, "comment_type": "Comment"}, fieldname="*")
comments = frappe.db.get_values(
"Comment",
filters={"reference_doctype": doctype, "reference_name": docname, "comment_type": "Comment"},
fieldname="*",
)
for comment in comments:
comment = frappe.get_doc(comment.update({"doctype":"Comment"}))
comment = frappe.get_doc(comment.update({"doctype": "Comment"}))
comment.name = None
comment.reference_doctype = doc.doctype
comment.reference_name = doc.name
comment.insert()
def add_link_in_communication(doctype, docname, doc):
communication_list = get_linked_communication_list(doctype, docname)
@@ -38,13 +48,15 @@ def add_link_in_communication(doctype, docname, doc):
communication_doc = frappe.get_doc("Communication", communication)
communication_doc.add_link(doc.doctype, doc.name, autosave=True)
def get_linked_communication_list(doctype, docname):
communications = frappe.get_all("Communication", filters={"reference_doctype": doctype, "reference_name": docname}, pluck='name')
communication_links = frappe.get_all('Communication Link',
{
"link_doctype": doctype,
"link_name": docname,
"parent": ("not in", communications)
}, pluck="parent")
communications = frappe.get_all(
"Communication", filters={"reference_doctype": doctype, "reference_name": docname}, pluck="name"
)
communication_links = frappe.get_all(
"Communication Link",
{"link_doctype": doctype, "link_name": docname, "parent": ("not in", communications)},
pluck="parent",
)
return communications + communication_links