Exemplo n.º 1
0
def get_transaction_list(doctype, txt=None, filters=None, limit_start=0, limit_page_length=20):
	from frappe.www.list import get_list
	user = frappe.session.user
	key = None

	if not filters: filters = []

	filters.append((doctype, "docstatus", "=", 1))

	if user != "Guest" and is_website_user():
		parties_doctype = 'Request for Quotation Supplier' if doctype == 'Request for Quotation' else doctype
		# find party for this contact
		customers, suppliers = get_customers_suppliers(parties_doctype, user)

		if not customers and not suppliers: return []

		key, parties = get_party_details(customers, suppliers)

		if doctype == 'Request for Quotation':
			return rfq_transaction_list(parties_doctype, doctype, parties, limit_start, limit_page_length)

		filters.append((doctype, key, "in", parties))

		if key:
			return post_process(doctype, get_list(doctype, txt,
				filters=filters, fields = "name",
				limit_start=limit_start, limit_page_length=limit_page_length,
				ignore_permissions=True,
				order_by = "modified desc"))
		else:
			return []

	return post_process(doctype, get_list(doctype, txt, filters, limit_start, limit_page_length,
		fields="name", order_by = "modified desc"))
def get_transaction_list(doctype,
                         txt=None,
                         filters=None,
                         limit_start=0,
                         limit_page_length=20):
    from frappe.www.list import get_list
    user = frappe.session.user
    key = None

    if not filters: filters = []

    if doctype == 'Supplier Quotation':
        filters.append((doctype, "docstatus", "<", 2))
    else:
        filters.append((doctype, "docstatus", "=", 1))

    if user != "Guest" and is_website_user():
        parties_doctype = 'Request for Quotation Supplier' if doctype == 'Request for Quotation' else doctype
        # find party for this contact
        customers, suppliers = get_customers_suppliers(parties_doctype, user)

        if not customers and not suppliers: return []

        key, parties = get_party_details(customers, suppliers)

        if doctype == 'Request for Quotation':
            return rfq_transaction_list(parties_doctype, doctype, parties,
                                        limit_start, limit_page_length)

        filters.append((doctype, key, "in", parties))

        if key:
            return post_process(
                doctype,
                get_list(doctype,
                         txt,
                         filters=filters,
                         fields="name",
                         limit_start=limit_start,
                         limit_page_length=limit_page_length,
                         ignore_permissions=True,
                         order_by="modified desc"))
        else:
            return []

    return post_process(
        doctype,
        get_list(doctype,
                 txt,
                 filters,
                 limit_start,
                 limit_page_length,
                 fields="name",
                 order_by="modified desc"))
Exemplo n.º 3
0
def get_list_for_transactions(doctype, txt, filters, limit_start, limit_page_length=20,
	ignore_permissions=False, fields=None, order_by=None):
	""" Get List of transactions like Invoices, Orders """
	from frappe.www.list import get_list
	meta = frappe.get_meta(doctype)
	data = []
	or_filters = []

	for d in get_list(doctype, txt, filters=filters, fields="name", limit_start=limit_start,
		limit_page_length=limit_page_length, ignore_permissions=ignore_permissions, order_by="modified desc"):
		data.append(d)

	if txt:
		if meta.get_field('items'):
			if meta.get_field('items').options:
				child_doctype = meta.get_field('items').options
				for item in frappe.get_all(child_doctype, {"item_name": ['like', "%" + txt + "%"]}):
					child = frappe.get_doc(child_doctype, item.name)
					or_filters.append([doctype, "name", "=", child.parent])

	if or_filters:
		for r in frappe.get_list(doctype, fields=fields,filters=filters, or_filters=or_filters,
			limit_start=limit_start, limit_page_length=limit_page_length,
			ignore_permissions=ignore_permissions, order_by=order_by):
			data.append(r)

	return data
Exemplo n.º 4
0
def get_discussions(doctype, txt, filters, limit_start, limit_page_length=20):
    from frappe.www.list import get_list

    if not filters:
        filters = []
        filters.append(("Discussion", "course", "=", frappe.form_dict.course))
    return get_list(doctype, txt, filters, limit_start, limit_page_length, ignore_permissions=True)
Exemplo n.º 5
0
def get_address_list(doctype, txt, filters, limit_start, limit_page_length = 20, order_by = None):
    from frappe.www.list import get_list
    user = frappe.session.user
    ignore_permissions = False
    if is_website_user():
        if not filters: filters = []
        add_name = []
        contact = frappe.db.sql("""
			select
				address.name
			from
				`tabDynamic Link` as link
			join
				`tabAddress` as address on link.parent = address.name
			where
				link.parenttype = 'Address' and
				link_name in(
				   select
					   link.link_name from `tabContact` as contact
				   join
					   `tabDynamic Link` as link on contact.name = link.parent
				   where
					   contact.user = %s)""",(user))
        for c in contact:
            add_name.append(c[0])
        filters.append(("Address", "name", "in", add_name))
        ignore_permissions = True

    return get_list(doctype, txt, filters, limit_start, limit_page_length, ignore_permissions=ignore_permissions)
Exemplo n.º 6
0
def get_issue_list(doctype,
                   txt,
                   filters,
                   limit_start,
                   limit_page_length=20,
                   order_by=None):
    from frappe.www.list import get_list

    user = frappe.session.user
    contact = frappe.db.get_value('Contact', {'user': user}, 'name')
    customer = None

    if contact:
        contact_doc = frappe.get_doc('Contact', contact)
        customer = contact_doc.get_link_for('Customer')

    ignore_permissions = False
    if is_website_user():
        if not filters: filters = []
        filters.append(("Issue", "customer", "=",
                        customer)) if customer else filters.append(
                            ("Issue", "raised_by", "=", user))
        ignore_permissions = True

    return get_list(doctype,
                    txt,
                    filters,
                    limit_start,
                    limit_page_length,
                    ignore_permissions=ignore_permissions)
Exemplo n.º 7
0
def get_issue_list(doctype,
                   txt,
                   filters,
                   limit_start,
                   limit_page_length=20,
                   order_by=None):
    from frappe.www.list import get_list

    user = frappe.session.user
    contact = frappe.db.get_value("Contact", {"user": user}, "name")
    customer = None

    if contact:
        contact_doc = frappe.get_doc("Contact", contact)
        customer = contact_doc.get_link_for("Customer")

    ignore_permissions = False
    if is_website_user():
        if not filters: filters = {}

        if customer:
            filters["customer"] = customer
        else:
            filters["raised_by"] = user

        ignore_permissions = True

    return get_list(doctype,
                    txt,
                    filters,
                    limit_start,
                    limit_page_length,
                    ignore_permissions=ignore_permissions)
def get_webform_transaction_list(doctype,
                                 txt=None,
                                 filters=None,
                                 limit_start=0,
                                 limit_page_length=20,
                                 order_by="modified"):
    """ Get List of transactions for custom doctypes """
    from frappe.www.list import get_list

    if not filters:
        filters = []

    meta = frappe.get_meta(doctype)

    for d in meta.fields:
        if d.fieldtype == 'Link' and d.fieldname != 'amended_from':
            allowed_docs = [
                d.name
                for d in get_transaction_list(doctype=d.options, custom=True)
            ]
            allowed_docs.append('')
            filters.append((d.fieldname, 'in', allowed_docs))

    return get_list(doctype,
                    txt,
                    filters,
                    limit_start,
                    limit_page_length,
                    ignore_permissions=False,
                    fields=None,
                    order_by="modified")
Exemplo n.º 9
0
def get_bookings_list(doctype,
                      txt,
                      filters,
                      limit_start,
                      limit_page_length=20,
                      order_by=None):
    from frappe.www.list import get_list
    user = frappe.session.user
    contact = frappe.db.get_value('Contact', {'user': user}, 'name')
    customer = None

    if contact:
        contact_doc = frappe.get_doc('Contact', contact)
        customer = contact_doc.get_link_for('Customer')

    if is_website_user():
        if not filters: filters = []

        or_filters = []
        or_filters.append({"user": user, "party_name": customer})

    return get_list(doctype,
                    txt,
                    filters,
                    limit_start,
                    limit_page_length,
                    ignore_permissions=False,
                    or_filters=or_filters)
Exemplo n.º 10
0
def get_address_list(doctype, txt, filters, limit_start, limit_page_length = 20, order_by = None):
    from frappe.www.list import get_list
    user = frappe.session.user
    ignore_permissions = False
    if is_website_user():
        if not filters: filters = []
        add_name = []
        contact = frappe.db.sql("""
			select
				address.name
			from
				`tabDynamic Link` as link
			join
				`tabAddress` as address on link.parent = address.name
			where
				link.parenttype = 'Address' and
				link_name in(
				   select
					   link.link_name from `tabContact` as contact
				   join
					   `tabDynamic Link` as link on contact.name = link.parent
				   where
					   contact.user = %s)""",(user))
        for c in contact:
            add_name.append(c[0])
        filters.append(("Address", "name", "in", add_name))
        ignore_permissions = True

    return get_list(doctype, txt, filters, limit_start, limit_page_length, ignore_permissions=ignore_permissions)
Exemplo n.º 11
0
def get_web_form_list(doctype, txt, filters, limit_start, limit_page_length=20):
	from frappe.www.list import get_list
	if not filters:
		filters = {}

	filters["owner"] = frappe.session.user

	return get_list(doctype, txt, filters, limit_start, limit_page_length, ignore_permissions=True)
Exemplo n.º 12
0
def get_web_form_list(doctype, txt, filters, limit_start, limit_page_length=20):
	from frappe.www.list import get_list
	if not filters:
		filters = {}

	filters["owner"] = frappe.session.user

	return get_list(doctype, txt, filters, limit_start, limit_page_length, ignore_permissions=True)
Exemplo n.º 13
0
def get_address_list(doctype, txt, filters, limit_start, limit_page_length = 20, order_by = None):
	from frappe.www.list import get_list
	user = frappe.session.user
	ignore_permissions = True

	if not filters: filters = []
	filters.append(("Address", "owner", "=", user))

	return get_list(doctype, txt, filters, limit_start, limit_page_length, ignore_permissions=ignore_permissions)
Exemplo n.º 14
0
def get_issue_list(doctype, txt, filters, limit_start, limit_page_length=20, order_by=None):
	from frappe.www.list import get_list
	user = frappe.session.user
	ignore_permissions = False
	if is_website_user():
		if not filters: filters = []
		filters.append(("Issue", "raised_by", "=", user))
		ignore_permissions = True

	return get_list(doctype, txt, filters, limit_start, limit_page_length, ignore_permissions=ignore_permissions)
Exemplo n.º 15
0
def get_address_list(doctype, txt, filters, limit_start, limit_page_length=20):
	from frappe.www.list import get_list
	user = frappe.session.user
	ignore_permissions = False
	if is_website_user():
		if not filters: filters = []
		filters.append(("Address", "owner", "=", user))
		ignore_permissions = True

	return get_list(doctype, txt, filters, limit_start, limit_page_length, ignore_permissions=ignore_permissions)
Exemplo n.º 16
0
def get_issue_list(doctype, txt, filters, limit_start, limit_page_length=20, order_by=None):
	from frappe.www.list import get_list
	user = frappe.session.user
	ignore_permissions = False
	if is_website_user():
		if not filters: filters = []
		filters.append(("Issue", "raised_by", "=", user))
		ignore_permissions = True

	return get_list(doctype, txt, filters, limit_start, limit_page_length, ignore_permissions=ignore_permissions)
Exemplo n.º 17
0
def get_address_list(doctype, txt, filters, limit_start, limit_page_length=20):
	from frappe.www.list import get_list
	user = frappe.session.user
	ignore_permissions = False
	if is_website_user():
		if not filters: filters = []
		filters.append(("Address", "owner", "=", user))
		ignore_permissions = True

	return get_list(doctype, txt, filters, limit_start, limit_page_length, ignore_permissions=ignore_permissions)
Exemplo n.º 18
0
def get_issue_list(doctype, txt, filters, limit_start, limit_page_length=20, order_by=None):
	from frappe.www.list import get_list
	user = frappe.session.user
	contact = frappe.db.get_value('Contact', {'user': user}, 'name')
	customer = None
	if contact:
		contact_doc = frappe.get_doc('Contact', contact)
		customer = contact_doc.get_link_for('Customer')

	ignore_permissions = False
	if is_website_user():
		if not filters: filters = []
		filters.append(("Issue", "customer", "=", customer)) if customer else filters.append(("Issue", "raised_by", "=", user))
		ignore_permissions = True

	return get_list(doctype, txt, filters, limit_start, limit_page_length, ignore_permissions=ignore_permissions)
Exemplo n.º 19
0
def get_discussions(doctype, txt, filters, limit_start, limit_page_length=20):
	from frappe.www.list import get_list
	if not filters:
		filters = []
		filters.append(("Discussion", "course", "=", frappe.form_dict.course))
	return get_list(doctype, txt, filters, limit_start, limit_page_length, ignore_permissions=True)