Exemple #1
0
		def _get_message(url=False):
			name = self.doc.name
			employee_name = cstr(employee.employee_name)
			if url:
				name = get_url_to_form(self.doc.doctype, self.doc.name)
				employee_name = get_url_to_form("Employee", self.doc.employee, label=employee_name)
			
			return (_("New Leave Application") + ": %s - " + _("Employee") + ": %s") % (name, employee_name)
		def _get_message(url=False):
			name = self.doc.name
			employee_name = cstr(employee.employee_name)
			if url:
				name = get_url_to_form(self.doc.doctype, self.doc.name)
				employee_name = get_url_to_form("Employee", self.doc.employee, label=employee_name)
			
			return (_("New Leave Application") + ": %s - " + _("Employee") + ": %s") % (name, employee_name)
		def _get_message(url=False):
			if url:
				name = get_url_to_form(self.doc.doctype, self.doc.name)
			else:
				name = self.doc.name
				
			return (_("Leave Application") + ": %s - %s") % (name, _(status))
Exemple #4
0
def _make_customer(source_name, ignore_permissions=False):
	quotation = webnotes.conn.get_value("Quotation", source_name, ["lead", "order_type"])
	if quotation and quotation[0]:
		lead_name = quotation[0]
		customer_name = webnotes.conn.get_value("Customer", {"lead_name": lead_name})
		if not customer_name:
			from selling.doctype.lead.lead import _make_customer
			customer_doclist = _make_customer(lead_name, ignore_permissions=ignore_permissions)
			customer = webnotes.bean(customer_doclist)
			customer.ignore_permissions = ignore_permissions
			if quotation[1] == "Shopping Cart":
				customer.doc.customer_group = webnotes.conn.get_value("Shopping Cart Settings", None,
					"default_customer_group")
			
			try:
				customer.insert()
				return customer
			except NameError, e:
				if webnotes.defaults.get_global_default('cust_master_name') == "Customer Name":
					customer.run_method("autoname")
					customer.doc.name += "-" + lead_name
					customer.insert()
					return customer
				else:
					raise
			except webnotes.MandatoryError:
				from webnotes.utils import get_url_to_form
				webnotes.throw(_("Before proceeding, please create Customer from Lead") + \
					(" - %s" % get_url_to_form("Lead", lead_name)))
Exemple #5
0
def _make_customer(source_name, ignore_permissions=False):
    quotation = webnotes.conn.get_value("Quotation", source_name,
                                        ["lead", "order_type"])
    if quotation and quotation[0]:
        lead_name = quotation[0]
        customer_name = webnotes.conn.get_value("Customer",
                                                {"lead_name": lead_name})
        if not customer_name:
            from selling.doctype.lead.lead import _make_customer
            customer_doclist = _make_customer(
                lead_name, ignore_permissions=ignore_permissions)
            customer = webnotes.bean(customer_doclist)
            customer.ignore_permissions = ignore_permissions
            if quotation[1] == "Shopping Cart":
                customer.doc.customer_group = webnotes.conn.get_value(
                    "Shopping Cart Settings", None, "default_customer_group")

            try:
                customer.insert()
                return customer
            except NameError, e:
                if webnotes.defaults.get_global_default(
                        'cust_master_name') == "Customer Name":
                    customer.run_method("autoname")
                    customer.doc.name += "-" + lead_name
                    customer.insert()
                    return customer
                else:
                    raise
            except webnotes.MandatoryError:
                from webnotes.utils import get_url_to_form
                webnotes.throw(_("Before proceeding, please create Customer from Lead") + \
                 (" - %s" % get_url_to_form("Lead", lead_name)))
Exemple #6
0
		def _get_message(url=False):
			if url:
				name = get_url_to_form(self.doc.doctype, self.doc.name)
			else:
				name = self.doc.name
				
			return (_("Leave Application") + ": %s - %s") % (name, _(status))
Exemple #7
0
def notify_assignment(assigned_by,
                      owner,
                      doc_type,
                      doc_name,
                      action='CLOSE',
                      description=None,
                      notify=0):
    """
		Notify assignee that there is a change in assignment
	"""
    if not (assigned_by and owner and doc_type and doc_name): return

    # self assignment / closing - no message
    if assigned_by == owner:
        return

    from webnotes.boot import get_fullnames
    user_info = get_fullnames()

    # Search for email address in description -- i.e. assignee
    from webnotes.utils import get_url_to_form
    assignment = get_url_to_form(doc_type,
                                 doc_name,
                                 label="%s: %s" % (doc_type, doc_name))

    if action == 'CLOSE':
        if owner == webnotes.session.get('user'):
            arg = {
                'contact':
                assigned_by,
                'txt':
                "The task %s, that you assigned to %s, has been \
					closed." % (assignment, user_info.get(owner, {}).get('fullname'))
            }
        else:
            arg = {
                'contact':
                assigned_by,
                'txt':
                "The task %s, that you assigned to %s, \
					has been closed	by %s." %
                (assignment, user_info.get(owner, {}).get('fullname'),
                 user_info.get(webnotes.session.get('user'),
                               {}).get('fullname'))
            }
    else:
        arg = {
         'contact': owner,
         'txt': "A new task, %s, has been assigned to you by %s. %s" \
          % (assignment,
          user_info.get(webnotes.session.get('user'), {}).get('fullname'),
          description and ("<p>Description: " + description + "</p>") or ""),
         'notify': notify
        }

    arg["parenttype"] = "Assignment"
    from core.page.messages import messages
    import json
    messages.post(json.dumps(arg))
Exemple #8
0
	def get_todo_list(self, user_id):
		from utilities.page.todo.todo import get
		todo_list = get()
		
		html = ""
		if todo_list:
			for i, todo in enumerate([todo for todo in todo_list if not todo.checked]):
				if i>= 10:
					break
				html += "<li style='line-height: 200%%'>%s [%s]</li>" % (todo.description or \
					get_url_to_form(todo.reference_type, todo.reference_name), todo.priority)
				
			
		return html and 1 or 0, "<h4>To Do (max 10):</h4><ul>" + html + "</ul><hr>"
Exemple #9
0
def notify_assignment(assigned_by, owner, doc_type, doc_name, action='CLOSE', 
	description=None, notify=0):
	"""
		Notify assignee that there is a change in assignment
	"""	
	if not (assigned_by and owner and doc_type and doc_name): return

	# self assignment / closing - no message
	if assigned_by==owner:
		return

	from webnotes.boot import get_fullnames
	user_info = get_fullnames()

	# Search for email address in description -- i.e. assignee
	from webnotes.utils import get_url_to_form
	assignment = get_url_to_form(doc_type, doc_name, label="%s: %s" % (doc_type, doc_name))
		
	if action=='CLOSE':
		if owner == webnotes.session.get('user'):
			arg = {
				'contact': assigned_by,
				'txt': "The task %s, that you assigned to %s, has been \
					closed." % (assignment,
						user_info.get(owner, {}).get('fullname'))
			}
		else:
			arg = {
				'contact': assigned_by,
				'txt': "The task %s, that you assigned to %s, \
					has been closed	by %s." % (assignment,
					user_info.get(owner, {}).get('fullname'),
					user_info.get(webnotes.session.get('user'),
						{}).get('fullname'))
			}
	else:
		arg = {
			'contact': owner,
			'txt': "A new task, %s, has been assigned to you by %s. %s" \
				% (assignment,
				user_info.get(webnotes.session.get('user'), {}).get('fullname'),
				description and ("<p>Description: " + description + "</p>") or ""),
			'notify': notify
		}
		
	arg["parenttype"] = "Assignment"
	from core.page.messages import messages
	import json
	messages.post(json.dumps(arg))
Exemple #10
0
	def send_email_notification(self, doc_type, doc_name, bean):
		""" Notify user about auto creation of indent"""
		
		from webnotes.utils.email_lib import sendmail
		email_list=[d[0] for d in sql("""select distinct r.parent from tabUserRole r, tabProfile p
			where p.name = r.parent and p.enabled = 1 and p.docstatus < 2
			and r.role in ('Purchase Manager','Material Manager') 
			and p.name not in ('Administrator', 'All', 'Guest')""")]
		
		msg="""A new Material Request has been raised for Item: %s and Warehouse: %s \
			on %s due to %s: %s. See %s: %s """ % (self.doc.item_code, self.doc.warehouse,
				formatdate(), doc_type, doc_name, bean.doc.doctype, 
				get_url_to_form(bean.doc.doctype, bean.doc.name))
		
		sendmail(email_list, subject='Auto Material Request Generation Notification', msg = msg)
Exemple #11
0
	def get_todo_list(self, user_id):
		from core.page.todo.todo import get
		todo_list = get()
		
		html = ""
		if todo_list:
			for i, todo in enumerate([todo for todo in todo_list if not todo.checked]):
				if i>= 10:
					break
				if not todo.description and todo.reference_type:
					todo.description = "%s: %s - %s %s" % \
					(todo.reference_type, get_url_to_form(todo.reference_type, todo.reference_name),
					_("assigned by"), get_fullname(todo.assigned_by))
					
				html += "<li style='line-height: 200%%'>%s [%s]</li>" % (todo.description, todo.priority)
				
		if html:
			return 1, "<h4>To Do (max 10):</h4><ul>" + html + "</ul><hr>"
		else:
			return 0, "<p>To Do</p>"