Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Merge branch 'hotfix'
  • Loading branch information
sahil28297 committed Apr 22, 2019
2 parents 2ae931b + 2454a85 commit 8a9897e
Show file tree
Hide file tree
Showing 16 changed files with 185 additions and 104 deletions.
2 changes: 1 addition & 1 deletion frappe/__init__.py
Expand Up @@ -24,7 +24,7 @@
reload(sys)
sys.setdefaultencoding("utf-8")

__version__ = '11.1.22'
__version__ = '11.1.23'
__title__ = "Frappe Framework"

local = Local()
Expand Down
114 changes: 111 additions & 3 deletions frappe/core/doctype/prepared_report/prepared_report.json
Expand Up @@ -21,6 +21,7 @@
"bold": 0,
"collapsible": 0,
"columns": 0,
"fetch_if_empty": 0,
"fieldname": "report_name",
"fieldtype": "Data",
"hidden": 1,
Expand Down Expand Up @@ -53,6 +54,7 @@
"bold": 0,
"collapsible": 0,
"columns": 0,
"fetch_if_empty": 0,
"fieldname": "ref_report_doctype",
"fieldtype": "Link",
"hidden": 1,
Expand Down Expand Up @@ -86,19 +88,21 @@
"bold": 0,
"collapsible": 0,
"columns": 0,
"default": "Queued",
"fetch_if_empty": 0,
"fieldname": "status",
"fieldtype": "Select",
"hidden": 1,
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0,
"in_global_search": 0,
"in_list_view": 0,
"in_list_view": 1,
"in_standard_filter": 0,
"label": "Status",
"length": 0,
"no_copy": 0,
"options": "Queued\nCompleted",
"options": "Error\nQueued\nCompleted",
"permlevel": 0,
"precision": "",
"print_hide": 0,
Expand All @@ -119,6 +123,39 @@
"bold": 0,
"collapsible": 0,
"columns": 0,
"fetch_if_empty": 0,
"fieldname": "column_break_4",
"fieldtype": "Column Break",
"hidden": 0,
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0,
"in_global_search": 0,
"in_list_view": 0,
"in_standard_filter": 0,
"length": 0,
"no_copy": 0,
"permlevel": 0,
"precision": "",
"print_hide": 0,
"print_hide_if_no_value": 0,
"read_only": 0,
"remember_last_selected_value": 0,
"report_hide": 0,
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"translatable": 0,
"unique": 0
},
{
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"fetch_if_empty": 0,
"fieldname": "report_start_time",
"fieldtype": "Datetime",
"hidden": 0,
Expand Down Expand Up @@ -151,6 +188,7 @@
"bold": 0,
"collapsible": 0,
"columns": 0,
"fetch_if_empty": 0,
"fieldname": "report_end_time",
"fieldtype": "Datetime",
"hidden": 0,
Expand Down Expand Up @@ -183,6 +221,73 @@
"bold": 0,
"collapsible": 0,
"columns": 0,
"depends_on": "eval:doc.status == 'Error'",
"fetch_if_empty": 0,
"fieldname": "section_break_7",
"fieldtype": "Section Break",
"hidden": 0,
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0,
"in_global_search": 0,
"in_list_view": 0,
"in_standard_filter": 0,
"length": 0,
"no_copy": 0,
"permlevel": 0,
"precision": "",
"print_hide": 0,
"print_hide_if_no_value": 0,
"read_only": 0,
"remember_last_selected_value": 0,
"report_hide": 0,
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"translatable": 0,
"unique": 0
},
{
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"fetch_if_empty": 0,
"fieldname": "error_message",
"fieldtype": "Text",
"hidden": 0,
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0,
"in_global_search": 0,
"in_list_view": 0,
"in_standard_filter": 0,
"label": "Error Message",
"length": 0,
"no_copy": 1,
"permlevel": 0,
"precision": "",
"print_hide": 1,
"print_hide_if_no_value": 0,
"read_only": 1,
"remember_last_selected_value": 0,
"report_hide": 0,
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"translatable": 0,
"unique": 0
},
{
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"fetch_if_empty": 0,
"fieldname": "filters_sb",
"fieldtype": "Section Break",
"hidden": 0,
Expand Down Expand Up @@ -215,6 +320,7 @@
"bold": 0,
"collapsible": 0,
"columns": 0,
"fetch_if_empty": 0,
"fieldname": "filters",
"fieldtype": "Small Text",
"hidden": 1,
Expand Down Expand Up @@ -247,6 +353,7 @@
"bold": 0,
"collapsible": 0,
"columns": 0,
"fetch_if_empty": 0,
"fieldname": "filter_values",
"fieldtype": "HTML",
"hidden": 0,
Expand Down Expand Up @@ -279,6 +386,7 @@
"bold": 0,
"collapsible": 0,
"columns": 0,
"fetch_if_empty": 0,
"fieldname": "columns",
"fieldtype": "Code",
"hidden": 1,
Expand Down Expand Up @@ -315,7 +423,7 @@
"issingle": 0,
"istable": 0,
"max_attachments": 0,
"modified": "2018-10-23 16:58:14.879417",
"modified": "2019-04-19 12:39:47.211516",
"modified_by": "Administrator",
"module": "Core",
"name": "Prepared Report",
Expand Down
43 changes: 26 additions & 17 deletions frappe/core/doctype/prepared_report/prepared_report.py
Expand Up @@ -25,31 +25,40 @@ def before_insert(self):
def after_insert(self):
enqueue(
run_background,
instance=self, timeout=6000
prepared_report=self.name, timeout=6000
)

def on_trash(self):
remove_all("PreparedReport", self.name, from_delete=True)


def run_background(instance):
def run_background(prepared_report):
instance = frappe.get_doc("Prepared Report", prepared_report)
report = frappe.get_doc("Report", instance.ref_report_doctype)

report.custom_columns = []

if report.report_type == 'Custom Report':
custom_report_doc = report
reference_report = custom_report_doc.reference_report
report = frappe.get_doc("Report", reference_report)
report.custom_columns = custom_report_doc.json

result = generate_report_result(report, filters=instance.filters, user=instance.owner)
create_json_gz_file(result['result'], 'Prepared Report', instance.name)

instance.status = "Completed"
instance.columns = json.dumps(result["columns"])
instance.report_end_time = frappe.utils.now()
instance.save()
try:
report.custom_columns = []

if report.report_type == 'Custom Report':
custom_report_doc = report
reference_report = custom_report_doc.reference_report
report = frappe.get_doc("Report", reference_report)
report.custom_columns = custom_report_doc.json

result = generate_report_result(report, filters=instance.filters, user=instance.owner)
create_json_gz_file(result['result'], 'Prepared Report', instance.name)

instance.status = "Completed"
instance.columns = json.dumps(result["columns"])
instance.report_end_time = frappe.utils.now()
instance.save()

except Exception:
frappe.log_error(frappe.get_traceback())
instance = frappe.get_doc("Prepared Report", prepared_report)
instance.status = "Error"
instance.error_message = frappe.get_traceback()
instance.save()

frappe.publish_realtime(
'report_generated',
Expand Down
12 changes: 12 additions & 0 deletions frappe/core/doctype/prepared_report/prepared_report_list.js
@@ -0,0 +1,12 @@
frappe.listview_settings['Prepared Report'] = {
add_fields: ["status"],
get_indicator: function(doc) {
if(doc.status==="Completed"){
return [__("Completed"), "green", "status,=,Completed"];
} else if(doc.status ==="Error"){
return [__("Error"), "red", "status,=,Error"];
} else if(doc.status ==="Queued"){
return [__("Queued"), "orange", "status,=,Queued"];
}
}
};
3 changes: 2 additions & 1 deletion frappe/desk/form/assign_to.py
Expand Up @@ -6,6 +6,7 @@

import frappe
from frappe import _
from frappe.utils import cint
from frappe.desk.form.load import get_docinfo
import frappe.share

Expand Down Expand Up @@ -160,7 +161,7 @@ def notify_assignment(assigned_by, owner, doc_type, doc_name, action='CLOSE',
'notify': notify
}

if arg and arg.get("notify"):
if arg and cint(arg.get("notify")):
_notify(arg)

def _notify(args):
Expand Down
2 changes: 1 addition & 1 deletion frappe/desk/query_report.py
Expand Up @@ -225,7 +225,7 @@ def add_data_to_custom_columns(columns, result):
fieldname = column['fieldname']
key = (column['doctype'], fieldname)
link_field = column['link_field']
row[fieldname] = custom_fields_data.get(key, {}).get(row[link_field])
row[fieldname] = custom_fields_data.get(key, {}).get(row.get(link_field))

return data

Expand Down
65 changes: 1 addition & 64 deletions frappe/email/inbox.py
Expand Up @@ -118,67 +118,4 @@ def link_communication_to_document(doc, reference_doctype, reference_name, ignor
doc.reference_doctype = reference_doctype
doc.reference_name = reference_name
doc.status = "Linked"
doc.save(ignore_permissions=True)

@frappe.whitelist()
def make_issue_from_communication(communication, ignore_communication_links=False):
""" raise a issue from email """

doc = frappe.get_doc("Communication", communication)
issue = frappe.get_doc({
"doctype": "Issue",
"subject": doc.subject,
"communication_medium": doc.communication_medium,
"raised_by": doc.sender or "",
"raised_by_phone": doc.phone_no or ""
}).insert(ignore_permissions=True)

link_communication_to_document(doc, "Issue", issue.name, ignore_communication_links)

return issue.name

@frappe.whitelist()
def make_lead_from_communication(communication, ignore_communication_links=False):
""" raise a issue from email """

doc = frappe.get_doc("Communication", communication)
lead_name = None
if doc.sender:
lead_name = frappe.db.get_value("Lead", {"email_id": doc.sender})
if not lead_name and doc.mobile_no:
lead_name = frappe.db.get_value("Lead", {"mobile_no": doc.phone_no})
if not lead_name:
lead = frappe.get_doc({
"doctype": "Lead",
"lead_name": doc.sender_full_name,
"email_id": doc.sender,
"mobile_no": doc.phone_no
})
lead.flags.ignore_mandatory = True
lead.flags.ignore_permissions = True
lead.insert()

lead_name = lead.name

link_communication_to_document(doc, "Lead", lead_name, ignore_communication_links)
return lead_name

@frappe.whitelist()
def make_opportunity_from_communication(communication, ignore_communication_links=False):
doc = frappe.get_doc("Communication", communication)

lead = doc.reference_name if doc.reference_doctype == "Lead" else None
if not lead:
lead = make_lead_from_communication(communication, ignore_communication_links=True)

enquiry_from = "Lead"

opportunity = frappe.get_doc({
"doctype": "Opportunity",
"enquiry_from": enquiry_from,
"lead": lead
}).insert(ignore_permissions=True)

link_communication_to_document(doc, "Opportunity", opportunity.name, ignore_communication_links)

return opportunity.name
doc.save(ignore_permissions=True)
1 change: 1 addition & 0 deletions frappe/hooks.py
Expand Up @@ -156,6 +156,7 @@
"frappe.utils.error.collect_error_snapshots",
"frappe.desk.page.backups.backups.delete_downloadable_backups",
"frappe.limits.update_space_usage",
"frappe.limits.update_site_usage",
"frappe.desk.doctype.auto_repeat.auto_repeat.make_auto_repeat_entry",
],
"daily": [
Expand Down

0 comments on commit 8a9897e

Please sign in to comment.