Auto email report fixes (#5410)
* fixes https://github.com/frappe/erpnext/issues/13319 * fixes https://github.com/frappe/erpnext/issues/13422 * change auto email report template * change auto email report template * Update data.py * Update data.py
This commit is contained in:
parent
9fea757559
commit
fb25fdb609
6 changed files with 18 additions and 14 deletions
|
|
@ -235,7 +235,7 @@ def add_total_row(result, columns, meta = None):
|
|||
def get_filtered_data(ref_doctype, columns, data, user):
|
||||
result = []
|
||||
linked_doctypes = get_linked_doctypes(columns, data)
|
||||
match_filters_per_doctype = get_user_match_filters(linked_doctypes, ref_doctype)
|
||||
match_filters_per_doctype = get_user_match_filters(linked_doctypes, user=user)
|
||||
shared = frappe.share.get_shared(ref_doctype, user)
|
||||
columns_dict = get_columns_dict(columns)
|
||||
|
||||
|
|
@ -380,11 +380,11 @@ def get_columns_dict(columns):
|
|||
|
||||
return columns_dict
|
||||
|
||||
def get_user_match_filters(doctypes, ref_doctype):
|
||||
def get_user_match_filters(doctypes, user):
|
||||
match_filters = {}
|
||||
|
||||
for dt in doctypes:
|
||||
filter_list = frappe.desk.reportview.build_match_conditions(dt, False)
|
||||
filter_list = frappe.desk.reportview.build_match_conditions(dt, user, False)
|
||||
if filter_list:
|
||||
match_filters[dt] = filter_list
|
||||
|
||||
|
|
|
|||
|
|
@ -341,8 +341,8 @@ def get_match_cond(doctype):
|
|||
cond = DatabaseQuery(doctype).build_match_conditions()
|
||||
return ((' and ' + cond) if cond else "").replace("%", "%%")
|
||||
|
||||
def build_match_conditions(doctype, as_condition=True):
|
||||
match_conditions = DatabaseQuery(doctype).build_match_conditions(as_condition=as_condition)
|
||||
def build_match_conditions(doctype, user, as_condition=True):
|
||||
match_conditions = DatabaseQuery(doctype, user=user).build_match_conditions(as_condition=as_condition)
|
||||
if as_condition:
|
||||
return match_conditions.replace("%", "%%")
|
||||
else:
|
||||
|
|
|
|||
|
|
@ -18,13 +18,13 @@ from frappe.model.utils.user_settings import get_user_settings, update_user_sett
|
|||
from datetime import datetime
|
||||
|
||||
class DatabaseQuery(object):
|
||||
def __init__(self, doctype):
|
||||
def __init__(self, doctype, user=None):
|
||||
self.doctype = doctype
|
||||
self.tables = []
|
||||
self.conditions = []
|
||||
self.or_conditions = []
|
||||
self.fields = None
|
||||
self.user = None
|
||||
self.user = user or frappe.session.user
|
||||
self.ignore_ifnull = False
|
||||
self.flags = frappe._dict()
|
||||
|
||||
|
|
|
|||
|
|
@ -109,7 +109,7 @@ frappe.views.QueryReport = class QueryReport extends frappe.views.BaseList {
|
|||
.then(doc => {
|
||||
this.report_doc = doc;
|
||||
})
|
||||
.then(() => frappe.model.with_doc('DocType', this.report_doc.ref_doctype));
|
||||
.then(() => frappe.model.with_doctype(this.report_doc.ref_doctype));
|
||||
}
|
||||
|
||||
get_report_settings() {
|
||||
|
|
|
|||
|
|
@ -1,11 +1,11 @@
|
|||
{% macro get_alignment(col) %}
|
||||
{%- if col.fieldtype in ('Int', 'Float', 'Currency', 'Check') %} class="text-right" {% endif -%}
|
||||
{% endmacro %}
|
||||
|
||||
<table class="report-title" border="0" cellpadding="0" cellspacing="0" width="100%">
|
||||
{% set max_width = '100%' if columns|length > 3 else '600px' %}
|
||||
<table class="report-title" border="0" cellpadding="0" cellspacing="0" width="100%" style="max-width: {{ max_width }}">
|
||||
<tr>
|
||||
<td>
|
||||
<b>{{ title }}</b> <span style="float: right">{{ date_time }}</span>
|
||||
<b>{{ title }}</b>
|
||||
</td>
|
||||
</tr>
|
||||
{% if description %}
|
||||
|
|
@ -15,7 +15,7 @@
|
|||
{% endif %}
|
||||
</table>
|
||||
{% if data %}
|
||||
<table class="table table-bordered text-medium" cellpadding="0" cellspacing="0" border="0" width="100%">
|
||||
<table class="table table-bordered text-medium" cellpadding="0" cellspacing="0" border="0" style="max-width: {{ max_width }}">
|
||||
<thead>
|
||||
<tr>
|
||||
{% for col in columns %}
|
||||
|
|
@ -38,10 +38,14 @@
|
|||
</tbody>
|
||||
</table>
|
||||
{% endif %}
|
||||
|
||||
{% if not frappe.db.get_value("System Settings", "System Settings", "hide_footer_in_auto_email_reports")|int %}
|
||||
<table class="more-info" border="0" cellpadding="0" cellspacing="0" width="100%">
|
||||
<table class="more-info" border="0" cellpadding="0" cellspacing="0" width="100%" style="max-width: {{ max_width }}">
|
||||
<tr>
|
||||
<td>
|
||||
<p>
|
||||
{{ _("This report was generated on {0}".format(date_time)) }}
|
||||
</p>
|
||||
<p>
|
||||
{{ _("View report in your browser") }}:
|
||||
<a href= {{report_url}} target="_blank">{{report_name}}</a>
|
||||
|
|
|
|||
|
|
@ -388,7 +388,7 @@ def fmt_money(amount, precision=None, currency=None):
|
|||
precision = len(decimals)
|
||||
|
||||
amount = '%.*f' % (precision, round(flt(amount), precision))
|
||||
|
||||
|
||||
if amount.find('.') == -1:
|
||||
decimals = ''
|
||||
else:
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue