diff --git a/crm/api/doc.py b/crm/api/doc.py index 576127a1a..07285e9e0 100644 --- a/crm/api/doc.py +++ b/crm/api/doc.py @@ -551,7 +551,9 @@ def get_fields_meta(doctype, restricted_fieldtypes=None, as_array=False): fields_meta = {} for field in fields: fields_meta[field.get('fieldname')] = field - + if field.get('fieldtype') == "Table": + _fields = frappe.get_meta(field.get('options')).fields + fields_meta[field.get('fieldname')] = {"df": field, "fields": _fields} return fields_meta @frappe.whitelist() diff --git a/crm/fcrm/doctype/crm_deal/api.py b/crm/fcrm/doctype/crm_deal/api.py index 76a764aed..2ca217ed9 100644 --- a/crm/fcrm/doctype/crm_deal/api.py +++ b/crm/fcrm/doctype/crm_deal/api.py @@ -1,33 +1,12 @@ import frappe -from frappe import _ from crm.api.doc import get_fields_meta, get_assigned_users from crm.fcrm.doctype.crm_form_script.crm_form_script import get_form_script @frappe.whitelist() def get_deal(name): - Deal = frappe.qb.DocType("CRM Deal") + deal = frappe.get_doc("CRM Deal", name).as_dict() - query = ( - frappe.qb.from_(Deal) - .select("*") - .where(Deal.name == name) - .limit(1) - ) - - deal = query.run(as_dict=True) - if not len(deal): - frappe.throw(_("Deal not found"), frappe.DoesNotExistError) - deal = deal.pop() - - - deal["contacts"] = frappe.get_all( - "CRM Contacts", - filters={"parenttype": "CRM Deal", "parent": deal.name}, - fields=["contact", "is_primary"], - ) - - deal["doctype"] = "CRM Deal" deal["fields_meta"] = get_fields_meta("CRM Deal") deal["_form_script"] = get_form_script('CRM Deal') deal["_assign"] = get_assigned_users("CRM Deal", deal.name, deal.owner) diff --git a/crm/fcrm/doctype/crm_lead/api.py b/crm/fcrm/doctype/crm_lead/api.py index e1bb4a4f5..160710684 100644 --- a/crm/fcrm/doctype/crm_lead/api.py +++ b/crm/fcrm/doctype/crm_lead/api.py @@ -6,16 +6,8 @@ @frappe.whitelist() def get_lead(name): - Lead = frappe.qb.DocType("CRM Lead") + lead = frappe.get_doc("CRM Lead", name).as_dict() - query = frappe.qb.from_(Lead).select("*").where(Lead.name == name).limit(1) - - lead = query.run(as_dict=True) - if not len(lead): - frappe.throw(_("Lead not found"), frappe.DoesNotExistError) - lead = lead.pop() - - lead["doctype"] = "CRM Lead" lead["fields_meta"] = get_fields_meta("CRM Lead") lead["_form_script"] = get_form_script('CRM Lead') lead["_assign"] = get_assigned_users("CRM Lead", lead.name, lead.owner) diff --git a/frontend/src/components/Activities/Activities.vue b/frontend/src/components/Activities/Activities.vue index 2a3f3dd67..89205f3c8 100644 --- a/frontend/src/components/Activities/Activities.vue +++ b/frontend/src/components/Activities/Activities.vue @@ -366,6 +366,9 @@ +