當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。