Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: package tag error #1439

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 17 additions & 17 deletions erpnext/controllers/queries.py
Original file line number Diff line number Diff line change
Expand Up @@ -376,41 +376,41 @@ def get_package_tags(doctype, txt, searchfield, start, page_len, filters):
if filters.get('warehouse'):
args.update({'warehouse': filters.get("warehouse")})
return frappe.db.sql("""
select sle.package_tag, tag.package_tag, tag.item_code, tag.item_name, tag.item_group, round(sum(sle.actual_qty),2)
from `tabStock Ledger Entry` sle
INNER JOIN `tabPackage Tag` tag
on sle.package_tag = tag.name
select `tabStock Ledger Entry`.package_tag, `tabPackage Tag`.package_tag, `tabPackage Tag`.item_code, `tabPackage Tag`.item_name, `tabPackage Tag`.item_group, round(sum(`tabStock Ledger Entry`.actual_qty),2)
from `tabStock Ledger Entry`
INNER JOIN `tabPackage Tag`
on `tabStock Ledger Entry`.package_tag = `tabPackage Tag`.name
where
{item_code}
and sle.warehouse = %(warehouse)s
and sle.package_tag like %(txt)s
and `tabStock Ledger Entry`.warehouse = %(warehouse)s
and `tabStock Ledger Entry`.package_tag like %(txt)s
{batch_no}
{company}
{match_conditions}
group by sle.package_tag having sum(sle.actual_qty) > 0
group by `tabStock Ledger Entry`.package_tag having sum(`tabStock Ledger Entry`.actual_qty) > 0
limit %(start)s, %(page_len)s""".format(
item_code="tag.item_code = %(item_code)s" if filters.get("item_code") else "tag.item_code is null",
batch_no="and sle.batch_no = {0}".format(frappe.db.escape(filters.get("batch_no"))) if filters.get("batch_no") else "",
company="and sle.company = {0}".format(frappe.db.escape(filters.get("company"))) if filters.get("company") else "",
item_code="`tabPackage Tag`.item_code = %(item_code)s" if filters.get("item_code") else "`tabPackage Tag`.item_code is null",
batch_no="and `tabStock Ledger Entry`.batch_no = {0}".format(frappe.db.escape(filters.get("batch_no"))) if filters.get("batch_no") else "",
company="and `tabStock Ledger Entry`.company = {0}".format(frappe.db.escape(filters.get("company"))) if filters.get("company") else "",
match_conditions=get_match_cond(doctype)
), args, debug=1, explain=1)
else:
if "is_used" in filters:
args.update({"is_used": filters.get("is_used")})

return frappe.db.sql("""select name, package_tag, item_code, item_name, item_group from `tabPackage Tag` package_tag
where package_tag.name like %(txt)s
return frappe.db.sql("""select name, package_tag, item_code, item_name, item_group from `tabPackage Tag`
where `tabPackage Tag`.name like %(txt)s
{item_code}
{is_used}
{batch_no}
{company}
{match_conditions}
order by package_tag.name desc
order by `tabPackage Tag`.name desc
limit %(start)s, %(page_len)s""".format(
item_code="and package_tag.item_code = %(item_code)s" if filters.get("item_code") else "",
is_used="and package_tag.is_used = %(is_used)s" if "is_used" in filters else "",
batch_no="and package_tag.batch_no = {0}".format(frappe.db.escape(filters.get("batch_no"))) if filters.get("batch_no") else "",
company = "and package_tag.company = {0}".format(frappe.db.escape(filters.get("company"))) if filters.get("company") else "",
item_code="and `tabPackage Tag`.item_code = %(item_code)s" if filters.get("item_code") else "",
is_used="and `tabPackage Tag`.is_used = %(is_used)s" if "is_used" in filters else "",
batch_no="and `tabPackage Tag`.batch_no = {0}".format(frappe.db.escape(filters.get("batch_no"))) if filters.get("batch_no") else "",
company = "and `tabPackage Tag`.company = {0}".format(frappe.db.escape(filters.get("company"))) if filters.get("company") else "",
match_conditions=get_match_cond(doctype)
), args)

Expand Down