Skip to content

Commit

Permalink
Merge branch 'develop' of github.com:frappe/frappe into drop-py2-code
Browse files Browse the repository at this point in the history
  • Loading branch information
gavindsouza committed May 31, 2021
2 parents 165ff8e + e82c9ed commit 8558116
Show file tree
Hide file tree
Showing 21 changed files with 1,011 additions and 402 deletions.
23 changes: 21 additions & 2 deletions frappe/core/doctype/communication/communication.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,11 @@
exclude_from_linked_with = True

class Communication(Document):
"""Communication represents an external communication like Email.
"""
no_feed_on_delete = True
DOCTYPE = 'Communication'

"""Communication represents an external communication like Email."""
def onload(self):
"""create email flag queue"""
if self.communication_type == "Communication" and self.communication_medium == "Email" \
Expand Down Expand Up @@ -148,6 +150,23 @@ def set_status(self):

self.email_status = "Spam"

@classmethod
def find(cls, name, ignore_error=False):
try:
return frappe.get_doc(cls.DOCTYPE, name)
except frappe.DoesNotExistError:
if ignore_error:
return
raise

@classmethod
def find_one_by_filters(cls, *, order_by=None, **kwargs):
name = frappe.db.get_value(cls.DOCTYPE, kwargs, order_by=order_by)
return cls.find(name) if name else None

def update_db(self, **kwargs):
frappe.db.set_value(self.DOCTYPE, self.name, kwargs)

def set_sender_full_name(self):
if not self.sender_full_name and self.sender:
if self.sender == "Administrator":
Expand Down Expand Up @@ -484,4 +503,4 @@ def set_avg_response_time(parent, communication):
response_times.append(response_time)
if response_times:
avg_response_time = sum(response_times) / len(response_times)
parent.db_set("avg_response_time", avg_response_time)
parent.db_set("avg_response_time", avg_response_time)
2 changes: 1 addition & 1 deletion frappe/core/doctype/data_import/data_import.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ frappe.ui.form.on('Data Import', {

if (frm.doc.status.includes('Success')) {
frm.add_custom_button(
__('Go to {0} List', [frm.doc.reference_doctype]),
__('Go to {0} List', [__(frm.doc.reference_doctype)]),
() => frappe.set_route('List', frm.doc.reference_doctype)
);
}
Expand Down
4 changes: 2 additions & 2 deletions frappe/core/doctype/doctype/doctype.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,11 @@ frappe.ui.form.on('DocType', {

if (!frm.is_new() && !frm.doc.istable) {
if (frm.doc.issingle) {
frm.add_custom_button(__('Go to {0}', [frm.doc.name]), () => {
frm.add_custom_button(__('Go to {0}', [__(frm.doc.name)]), () => {
window.open(`/app/${frappe.router.slug(frm.doc.name)}`);
});
} else {
frm.add_custom_button(__('Go to {0} List', [frm.doc.name]), () => {
frm.add_custom_button(__('Go to {0} List', [__(frm.doc.name)]), () => {
window.open(`/app/${frappe.router.slug(frm.doc.name)}`);
});
}
Expand Down
2 changes: 1 addition & 1 deletion frappe/custom/doctype/customize_form/customize_form.js
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ frappe.ui.form.on("Customize Form", {
frappe.customize_form.set_primary_action(frm);

frm.add_custom_button(
__("Go to {0} List", [frm.doc.doc_type]),
__("Go to {0} List", [__(frm.doc.doc_type)]),
function() {
frappe.set_route("List", frm.doc.doc_type);
},
Expand Down
8 changes: 5 additions & 3 deletions frappe/email/doctype/auto_email_report/auto_email_report.py
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,7 @@ def send_monthly():

def make_links(columns, data):
for row in data:
doc_name = row.get('name')
for col in columns:
if col.fieldtype == "Link" and col.options != "Currency":
if col.options and row.get(col.fieldname):
Expand All @@ -251,13 +252,14 @@ def make_links(columns, data):
if col.options and row.get(col.fieldname) and row.get(col.options):
row[col.fieldname] = get_link_to_form(row[col.options], row[col.fieldname])
elif col.fieldtype == "Currency" and row.get(col.fieldname):
row[col.fieldname] = frappe.format_value(row[col.fieldname], col)

doc = frappe.get_doc(col.parent, doc_name) if doc_name else None
# Pass the Document to get the currency based on docfield option
row[col.fieldname] = frappe.format_value(row[col.fieldname], col, doc=doc)
return columns, data

def update_field_types(columns):
for col in columns:
if col.fieldtype in ("Link", "Dynamic Link", "Currency") and col.options != "Currency":
col.fieldtype = "Data"
col.options = ""
return columns
return columns

0 comments on commit 8558116

Please sign in to comment.