当前位置: 首页>>代码示例>>Python>>正文


Python frappe.utils方法代码示例

本文整理汇总了Python中frappe.utils方法的典型用法代码示例。如果您正苦于以下问题:Python frappe.utils方法的具体用法?Python frappe.utils怎么用?Python frappe.utils使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在frappe的用法示例。


在下文中一共展示了frappe.utils方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: daily

# 需要导入模块: import frappe [as 别名]
# 或者: from frappe import utils [as 别名]
def daily():
    users = frappe.db.sql("""select email, name from tabUser
        where name in (select parent from tabUserRole
        where role='Accounts Manager')""", as_dict=1)
    today = nowdate()
    end = add_days(today, 3)
    sales_invoices = frappe.db.sql("""select name from `tabSales Invoice`
        where (date(due_date) between date(%(start)s) and date(%(end)s))
        and outstanding_amount > 0
        and docstatus=1""", {
        "start": today,
        "end": end,
    }, as_dict=1)
    if sales_invoices:
        subject = "Outstanding sales invoices due %s" % today
        message = "<p>Please review and follow up with the customers on the outstanding sales invoices below:</p><ul>"
        from frappe.utils import get_link_to_form
        for si in sales_invoices:
            message += "<li>" + get_link_to_form("Sales Invoice", si.name, si.name) + "</li>"
        message += "</ul><p><b>Note:</b> The list above contains the invoices that are either overdue or have its due date within the next 3 business days</p>"

        frappe.sendmail(recipients=[u.email for u in users], subject=subject, message=message, reply_to=EMAIL_SENDER, bulk=True)
        formatted_si = ", ".join(si.name for si in sales_invoices)
        for u in [u.name for u in users]:
            todo_doc = frappe.get_doc({
                "doctype": "ToDo",
                "owner": u,
                "description": subject + ": " + formatted_si,
                "priority": "Medium",
                "status": "Open",
                "role": "Accounts Manager",
                "date": nowdate(),
                "assigned_by": frappe.session.user,
            })
            todo_doc.insert(ignore_permissions=True) 
开发者ID:nataliamm,项目名称:erpnext-warranty-management,代码行数:37,代码来源:tasks.py

示例2: export_my_query

# 需要导入模块: import frappe [as 别名]
# 或者: from frappe import utils [as 别名]
def export_my_query(filters, ws=None,wb=None):

	data = frappe._dict(frappe.local.form_dict)
	del data["cmd"]
	if "csrf_token" in data:
		del data["csrf_token"]
		
	if isinstance(data.get("report_name"), string_types):
		report_name = data["report_name"]
	
	data = run("Employee Yearly Summary", filters)
	data = frappe._dict(data)
	columns = get_columns_dict(data.columns)

	result = [[]]

	# add column headings
	for idx in range(len(data.columns)):
		result[0].append(columns[idx]["label"])

	# build table from dict
	if isinstance(data.result[0], dict):
		for i,row in enumerate(data.result):
			# only rows which are visible in the report
			if row:
				row_list = []
				for idx in range(len(data.columns)):
					row_list.append(row.get(columns[idx]["fieldname"],""))
				result.append(row_list)
			elif not row:
				result.append([])
	else:
		result = result + [d for i,d in enumerate(data.result)]

	from frappe.utils.xlsxutils import make_xlsx
	if ws is None:
		ws = "Query Report"
	xlsx_file = make_xlsx(result, ws, wb)
	
	frappe.response['filename'] = report_name + '.xlsx'
	frappe.response['filecontent'] = xlsx_file.getvalue()
	frappe.response['type'] = 'binary' 
开发者ID:bcornwellmott,项目名称:velometro,代码行数:44,代码来源:employee_yearly_summary.py


注:本文中的frappe.utils方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。