Пример #1
0
def notify_errors(inv, owner):
	import webnotes
	import website
		
	exception_msg = """
		Dear User,

		An error occured while creating recurring invoice from %s (at %s).

		May be there are some invalid email ids mentioned in the invoice.

		To stop sending repetitive error notifications from the system, we have unchecked
		"Convert into Recurring" field in the invoice %s.


		Please correct the invoice and make the invoice recurring again. 

		<b>It is necessary to take this action today itself for the above mentioned recurring invoice \
		to be generated. If delayed, you will have to manually change the "Repeat on Day of Month" field \
		of this invoice for generating the recurring invoice.</b>

		Regards,
		Administrator
		
	""" % (inv, website.get_site_address(), inv)
	subj = "[Urgent] Error while creating recurring invoice from %s" % inv

	from webnotes.profile import get_system_managers
	recipients = get_system_managers()
	owner_email = webnotes.conn.get_value("Profile", owner, "email")
	if not owner_email in recipients:
		recipients.append(owner_email)

	assign_task_to_owner(inv, exception_msg, recipients)
	sendmail(recipients, subject=subj, msg = exception_msg)
def execute():
	webnotes.reload_doc("setup", "doctype", "email_digest")
	
	from webnotes.profile import get_system_managers
	system_managers = get_system_managers(only_name=True)
	if not system_managers: 
		return
	
	# no default company
	company = webnotes.conn.get_default("company")
	if not company:
		company = webnotes.conn.sql_list("select name from `tabCompany`")
		if company:
			company = company[0]
	if not company:
		return
	
	# scheduler errors digest
	edigest = webnotes.new_bean("Email Digest")
	edigest.doc.fields.update({
		"name": "Scheduler Errors",
		"company": company,
		"frequency": "Daily",
		"enabled": 1,
		"recipient_list": "\n".join(system_managers),
		"scheduler_errors": 1
	})
	edigest.insert()
Пример #3
0
	def create_email_digest(self):
		"""
			create a default weekly email digest
			* Weekly Digest
			* For all companies
			* Recipients: System Managers
			* Full content
			* Enabled by default
		"""
		import webnotes
		companies_list = webnotes.conn.sql("SELECT company_name FROM `tabCompany`", as_list=1)

		from webnotes.profile import get_system_managers
		system_managers = get_system_managers()
		if not system_managers: return
		
		from webnotes.model.doc import Document
		for company in companies_list:
			if company and company[0]:
				edigest = webnotes.bean({
					"doctype": "Email Digest",
					"name": "Default Weekly Digest - " + company[0],
					"company": company[0],
					"frequency": "Weekly",
					"recipient_list": "\n".join(system_managers)
				})
				
				if webnotes.conn.sql("""select name from `tabEmail Digest` where name=%s""", edigest.doc.name):
					continue
				
				for fieldname in edigest.meta.get_fieldnames({"fieldtype": "Check"}):
					edigest.doc.fields[fieldname] = 1
					
				edigest.insert()
Пример #4
0
def create_email_digest():
    from webnotes.profile import get_system_managers
    system_managers = get_system_managers()
    if not system_managers:
        return

    for company in webnotes.conn.sql_list("select name FROM `tabCompany`"):
        if not webnotes.conn.exists("Email Digest",
                                    "Default Weekly Digest - " + company):
            edigest = webnotes.bean({
                "doctype":
                "Email Digest",
                "name":
                "Default Weekly Digest - " + company,
                "company":
                company,
                "frequency":
                "Weekly",
                "recipient_list":
                "\n".join(system_managers)
            })

            for fieldname in edigest.meta.get_fieldnames(
                {"fieldtype": "Check"}):
                edigest.doc.fields[fieldname] = 1

            edigest.insert()
Пример #5
0
def create_email_digest():
	from webnotes.profile import get_system_managers
	system_managers = get_system_managers(only_name=True)
	if not system_managers: 
		return
	
	companies = webnotes.conn.sql_list("select name FROM `tabCompany`")
	for company in companies:
		if not webnotes.conn.exists("Email Digest", "Default Weekly Digest - " + company):
			edigest = webnotes.bean({
				"doctype": "Email Digest",
				"name": "Default Weekly Digest - " + company,
				"company": company,
				"frequency": "Weekly",
				"recipient_list": "\n".join(system_managers)
			})

			for fieldname in edigest.meta.get_fieldnames({"fieldtype": "Check"}):
				if fieldname != "scheduler_errors":
					edigest.doc.fields[fieldname] = 1
		
			edigest.insert()
	
	# scheduler errors digest
	if companies:
		edigest = webnotes.new_bean("Email Digest")
		edigest.doc.fields.update({
			"name": "Scheduler Errors",
			"company": companies[0],
			"frequency": "Daily",
			"recipient_list": "\n".join(system_managers),
			"scheduler_errors": 1,
			"enabled": 1
		})
		edigest.insert()
Пример #6
0
def create_email_digest():
	from webnotes.profile import get_system_managers
	system_managers = get_system_managers(only_name=True)
	if not system_managers: 
		return
	
	for company in webnotes.conn.sql_list("select name FROM `tabCompany`"):
		if not webnotes.conn.exists("Email Digest", "Default Weekly Digest - " + company):
			edigest = webnotes.bean({
				"doctype": "Email Digest",
				"name": "Default Weekly Digest - " + company,
				"company": company,
				"frequency": "Weekly",
				"recipient_list": "\n".join(system_managers)
			})

			for fieldname in edigest.meta.get_fieldnames({"fieldtype": "Check"}):
				if fieldname != "scheduler_errors":
					edigest.doc.fields[fieldname] = 1
		
			edigest.insert()
	
	# scheduler errors digest
	edigest = webnotes.new_bean("Email Digest")
	edigest.doc.fields.update({
		"name": "Scheduler Errors",
		"company": webnotes.conn.get_default("company"),
		"frequency": "Daily",
		"recipient_list": "\n".join(system_managers),
		"scheduler_errors": 1,
		"enabled": 1
	})
	edigest.insert()
Пример #7
0
def execute():
    webnotes.reload_doc("setup", "doctype", "email_digest")

    from webnotes.profile import get_system_managers
    system_managers = get_system_managers(only_name=True)
    if not system_managers:
        return

    # no default company
    company = webnotes.conn.sql_list("select name from `tabCompany`")
    if company:
        company = company[0]
    if not company:
        return

    # scheduler errors digest
    edigest = webnotes.new_bean("Email Digest")
    edigest.doc.fields.update({
        "name": "Scheduler Errors",
        "company": company,
        "frequency": "Daily",
        "enabled": 1,
        "recipient_list": "\n".join(system_managers),
        "scheduler_errors": 1
    })
    edigest.insert()
Пример #8
0
    def create_email_digest(self):
        """
			create a default weekly email digest
			* Weekly Digest
			* For all companies
			* Recipients: System Managers
			* Full content
			* Enabled by default
		"""
        import webnotes

        companies_list = webnotes.conn.sql("SELECT company_name FROM `tabCompany`", as_list=1)

        from webnotes.profile import get_system_managers

        system_managers = get_system_managers()
        if not system_managers:
            return

        from webnotes.model.doc import Document

        for company in companies_list:
            if company and company[0]:
                edigest = Document("Email Digest")
                edigest.name = "Default Weekly Digest - " + company[0]
                edigest.company = company[0]
                edigest.frequency = "Weekly"
                edigest.recipient_list = "\n".join(system_managers)
                for f in [
                    "new_leads",
                    "new_enquiries",
                    "new_quotations",
                    "new_sales_orders",
                    "new_purchase_orders",
                    "new_transactions",
                    "payables",
                    "payments",
                    "expenses_booked",
                    "invoiced_amount",
                    "collections",
                    "income",
                    "bank_balance",
                    "stock_below_rl",
                    "income_year_to_date",
                    "enabled",
                ]:
                    edigest.fields[f] = 1
                exists = webnotes.conn.sql(
                    """\
					SELECT name FROM `tabEmail Digest`
					WHERE name = %s""",
                    edigest.name,
                )
                if (exists and exists[0]) and exists[0][0]:
                    continue
                else:
                    edigest.save(1)
Пример #9
0
def notify_errors(exceptions_list):
	subject = "[Important] [Owrang] Error(s) while creating Material Requests based on Re-order Levels"
	msg = """Dear System Manager,

		An error occured for certain Items while creating Material Requests based on Re-order level.
		
		Please rectify these issues:
		---

		%s

		---
		Regards,
		Administrator""" % ("\n\n".join(["\n".join(msg) for msg in exceptions_list]),)

	from webnotes.profile import get_system_managers
	sendmail(get_system_managers(), subject=subject, msg=msg)
Пример #10
0
def notify_errors(exceptions_list):
	subject = "[Important] [ERPNext] Error(s) while creating Material Requests based on Re-order Levels"
	msg = """Dear System Manager,

		An error occured for certain Items while creating Material Requests based on Re-order level.
		
		Please rectify these issues:
		---

		%s

		---
		Regards,
		Administrator""" % ("\n\n".join(["\n".join(msg) for msg in exceptions_list]),)

	from webnotes.profile import get_system_managers
	sendmail(get_system_managers(), subject=subject, msg=msg)
def execute():
	from webnotes.profile import get_system_managers
	system_managers = get_system_managers(only_name=True)
	if not system_managers: 
		return
	
	# scheduler errors digest
	edigest = webnotes.new_bean("Email Digest")
	edigest.doc.fields.update({
		"name": "Scheduler Errors",
		"company": webnotes.conn.get_default("company"),
		"frequency": "Daily",
		"enabled": 1,
		"recipient_list": "\n".join(system_managers),
		"scheduler_errors": 1
	})
	edigest.insert()
Пример #12
0
    def create_email_digest(self):
        """
			create a default weekly email digest
			* Weekly Digest
			* For all companies
			* Recipients: System Managers
			* Full content
			* Enabled by default
		"""
        import webnotes
        companies_list = webnotes.conn.sql(
            "SELECT company_name FROM `tabCompany`", as_list=1)

        from webnotes.profile import get_system_managers
        system_managers = get_system_managers()
        if not system_managers: return

        from webnotes.model.doc import Document
        for company in companies_list:
            if company and company[0]:
                edigest = webnotes.bean({
                    "doctype":
                    "Email Digest",
                    "name":
                    "Default Weekly Digest - " + company[0],
                    "company":
                    company[0],
                    "frequency":
                    "Weekly",
                    "recipient_list":
                    "\n".join(system_managers)
                })

                if webnotes.conn.sql(
                        """select name from `tabEmail Digest` where name=%s""",
                        edigest.doc.name):
                    continue

                for fieldname in edigest.meta.get_fieldnames(
                    {"fieldtype": "Check"}):
                    edigest.doc.fields[fieldname] = 1

                edigest.insert()
Пример #13
0
    def create_email_digest(self):
        """
			create a default weekly email digest
			* Weekly Digest
			* For all companies
			* Recipients: System Managers
			* Full content
			* Enabled by default
		"""
        import webnotes
        companies_list = webnotes.conn.sql(
            "SELECT company_name FROM `tabCompany`", as_list=1)

        from webnotes.profile import get_system_managers
        system_managers = get_system_managers()
        if not system_managers: return

        from webnotes.model.doc import Document
        for company in companies_list:
            if company and company[0]:
                edigest = Document('Email Digest')
                edigest.name = "Default Weekly Digest - " + company[0]
                edigest.company = company[0]
                edigest.frequency = 'Weekly'
                edigest.recipient_list = "\n".join(system_managers)
                for f in [
                        'new_leads', 'new_enquiries', 'new_quotations',
                        'new_sales_orders', 'new_purchase_orders',
                        'new_transactions', 'payables', 'payments',
                        'expenses_booked', 'invoiced_amount', 'collections',
                        'income', 'bank_balance', 'stock_below_rl',
                        'income_year_to_date', 'enabled'
                ]:
                    edigest.fields[f] = 1
                exists = webnotes.conn.sql(
                    """\
					SELECT name FROM `tabEmail Digest`
					WHERE name = %s""", edigest.name)
                if (exists and exists[0]) and exists[0][0]:
                    continue
                else:
                    edigest.save(1)
Пример #14
0
def create_email_digest():
	from webnotes.profile import get_system_managers
	system_managers = get_system_managers()
	if not system_managers: 
		return
	
	for company in webnotes.conn.sql_list("select name FROM `tabCompany`"):
		if not webnotes.conn.exists("Email Digest", "Default Weekly Digest - " + company):
			edigest = webnotes.bean({
				"doctype": "Email Digest",
				"name": "Default Weekly Digest - " + company,
				"company": company,
				"frequency": "Weekly",
				"recipient_list": "\n".join(system_managers)
			})

			for fieldname in edigest.meta.get_fieldnames({"fieldtype": "Check"}):
				edigest.doc.fields[fieldname] = 1
		
			edigest.insert()
Пример #15
0
def get_site_status(site=None, verbose=False):
    import webnotes
    import webnotes.utils
    from webnotes.profile import get_system_managers
    from core.doctype.profile.profile import get_total_users, get_active_users, \
     get_website_users, get_active_website_users

    import json
    webnotes.connect(site=site)
    ret = {
        'last_backup_on': webnotes.local.conf.last_backup_on,
        'active_users': get_active_users(),
        'total_users': get_total_users(),
        'active_website_users': get_active_website_users(),
        'website_users': get_website_users(),
        'system_managers': "\n".join(get_system_managers()),
        'default_company': webnotes.conn.get_default("company"),
        'disk_usage': webnotes.utils.get_disk_usage(),
        'working_directory': webnotes.utils.get_base_path()
    }

    # country, timezone, industry
    control_panel_details = webnotes.conn.get_value(
        "Control Panel",
        "Control Panel", ["country", "time_zone", "industry"],
        as_dict=True)
    if control_panel_details:
        ret.update(control_panel_details)

    # basic usage/progress analytics
    for doctype in ("Company", "Customer", "Item", "Quotation",
                    "Sales Invoice", "Journal Voucher", "Stock Ledger Entry"):
        key = doctype.lower().replace(" ", "_") + "_exists"
        ret[key] = 1 if webnotes.conn.count(doctype) else 0

    webnotes.destroy()

    if verbose:
        print json.dumps(ret, indent=1, sort_keys=True)

    return ret
Пример #16
0
def get_site_status(site=None, verbose=False):
	import webnotes
	import webnotes.utils
	from webnotes.profile import get_system_managers
	from core.doctype.profile.profile import get_total_users, get_active_users, \
		get_website_users, get_active_website_users
	
	import json
	webnotes.connect(site=site)
	ret = {
		'last_backup_on': webnotes.local.conf.last_backup_on,
		'active_users': get_active_users(),
		'total_users': get_total_users(),
		'active_website_users': get_active_website_users(),
		'website_users': get_website_users(),
		'system_managers': "\n".join(get_system_managers()),
		'default_company': webnotes.conn.get_default("company"),
		'disk_usage': webnotes.utils.get_disk_usage(),
		'working_directory': webnotes.utils.get_base_path()
	}
	
	# country, timezone, industry
	control_panel_details = webnotes.conn.get_value("Control Panel", "Control Panel", 
		["country", "time_zone", "industry"], as_dict=True)
	if control_panel_details:
		ret.update(control_panel_details)
	
	# basic usage/progress analytics
	for doctype in ("Company", "Customer", "Item", "Quotation", "Sales Invoice",
		"Journal Voucher", "Stock Ledger Entry"):
			key = doctype.lower().replace(" ", "_") + "_exists"
			ret[key] = 1 if webnotes.conn.count(doctype) else 0
			
	webnotes.destroy()
	
	if verbose:
		print json.dumps(ret, indent=1, sort_keys=True)
	
	return ret