mirror of
https://github.com/frappe/erpnext.git
synced 2026-04-26 01:58:31 +00:00
fix: add parenttype condition for item table in Purchase Register Report
(cherry picked from commit 28abf191fc)
This commit is contained in:
@@ -311,6 +311,7 @@ def get_account_columns(invoice_list, include_payments):
|
|||||||
"""select distinct expense_account
|
"""select distinct expense_account
|
||||||
from `tabPurchase Invoice Item` where docstatus = 1
|
from `tabPurchase Invoice Item` where docstatus = 1
|
||||||
and (expense_account is not null and expense_account != '')
|
and (expense_account is not null and expense_account != '')
|
||||||
|
and parenttype='Purchase Invoice'
|
||||||
and parent in (%s) order by expense_account"""
|
and parent in (%s) order by expense_account"""
|
||||||
% ", ".join(["%s"] * len(invoice_list)),
|
% ", ".join(["%s"] * len(invoice_list)),
|
||||||
tuple([inv.name for inv in invoice_list]),
|
tuple([inv.name for inv in invoice_list]),
|
||||||
@@ -451,7 +452,7 @@ def get_invoice_expense_map(invoice_list):
|
|||||||
"""
|
"""
|
||||||
select parent, expense_account, sum(base_net_amount) as amount
|
select parent, expense_account, sum(base_net_amount) as amount
|
||||||
from `tabPurchase Invoice Item`
|
from `tabPurchase Invoice Item`
|
||||||
where parent in (%s)
|
where parent in (%s) and parenttype='Purchase Invoice'
|
||||||
group by parent, expense_account
|
group by parent, expense_account
|
||||||
"""
|
"""
|
||||||
% ", ".join(["%s"] * len(invoice_list)),
|
% ", ".join(["%s"] * len(invoice_list)),
|
||||||
@@ -522,7 +523,7 @@ def get_invoice_po_pr_map(invoice_list):
|
|||||||
"""
|
"""
|
||||||
select parent, purchase_order, purchase_receipt, po_detail, project
|
select parent, purchase_order, purchase_receipt, po_detail, project
|
||||||
from `tabPurchase Invoice Item`
|
from `tabPurchase Invoice Item`
|
||||||
where parent in (%s)
|
where parent in (%s) and parenttype='Purchase Invoice'
|
||||||
"""
|
"""
|
||||||
% ", ".join(["%s"] * len(invoice_list)),
|
% ", ".join(["%s"] * len(invoice_list)),
|
||||||
tuple(inv.name for inv in invoice_list),
|
tuple(inv.name for inv in invoice_list),
|
||||||
|
|||||||
@@ -326,6 +326,7 @@ def apply_common_conditions(filters, query, doctype, child_doctype=None, payment
|
|||||||
|
|
||||||
if join_required:
|
if join_required:
|
||||||
query = query.inner_join(child_doc).on(parent_doc.name == child_doc.parent)
|
query = query.inner_join(child_doc).on(parent_doc.name == child_doc.parent)
|
||||||
|
query = query.where(child_doc.parenttype == doctype)
|
||||||
query = query.distinct()
|
query = query.distinct()
|
||||||
|
|
||||||
if parent_doc.get_table_name() != "tabJournal Entry":
|
if parent_doc.get_table_name() != "tabJournal Entry":
|
||||||
|
|||||||
Reference in New Issue
Block a user