diff --git a/erpnext/accounts/print_format/purchase_auditing_voucher/purchase_auditing_voucher.html b/erpnext/accounts/print_format/purchase_auditing_voucher/purchase_auditing_voucher.html
index 342ce22b3a7..6c53a7ade51 100644
--- a/erpnext/accounts/print_format/purchase_auditing_voucher/purchase_auditing_voucher.html
+++ b/erpnext/accounts/print_format/purchase_auditing_voucher/purchase_auditing_voucher.html
@@ -1,5 +1,6 @@
{%- from "templates/print_formats/standard_macros.html" import add_header -%}
+ {% set gl = frappe.get_list(doctype="GL Entry", fields=["account", "party_type", "party", "debit", "credit", "remarks"], filters={"voucher_type": doc.doctype, "voucher_no": doc.name}) %}
{%- if not doc.get("print_heading") and not doc.get("select_print_heading")
and doc.set("select_print_heading", _("Purchase Invoice")) -%}{%- endif -%}
{{ add_header(0, 1, doc, letter_head, no_letterhead, print_settings) }}
@@ -62,7 +63,7 @@
{% for tax in doc.taxes %}
{% if tax.tax_amount_after_discount_amount!= 0 %}
| {{ tax.account_head }}: | {{ tax.tax_amount_after_discount_amount }} |
-
+ {% endif %}
{% endfor %}
{% if doc.taxes_and_charges_added!= 0 %}
| Taxes and Charges Added: | {{ doc.taxes_and_charges_added }} |
@@ -85,7 +86,7 @@
Debit Amount |
Credit Amount |
- {% for entries in doc.gl_entries %}
+ {% for entries in gl %}
| {{ loop.index }} |
{{ entries.account }} |
diff --git a/erpnext/accounts/print_format/sales_auditing_voucher/sales_auditing_voucher.html b/erpnext/accounts/print_format/sales_auditing_voucher/sales_auditing_voucher.html
index 4dc4b8a4a92..1c3fb6aee96 100644
--- a/erpnext/accounts/print_format/sales_auditing_voucher/sales_auditing_voucher.html
+++ b/erpnext/accounts/print_format/sales_auditing_voucher/sales_auditing_voucher.html
@@ -1,5 +1,6 @@
{%- from "templates/print_formats/standard_macros.html" import add_header -%}
+ {% set gl = frappe.get_list(doctype="GL Entry", fields=["account", "party_type", "party", "debit", "credit", "remarks"], filters={"voucher_type": doc.doctype, "voucher_no": doc.name}) %}
{%- if not doc.get("print_heading") and not doc.get("select_print_heading")
and doc.set("select_print_heading", _("Sales Invoice")) -%}{%- endif -%}
{{ add_header(0, 1, doc, letter_head, no_letterhead, print_settings) }}
@@ -75,7 +76,7 @@
Debit Amount |
Credit Amount |
- {% for entries in doc.gl_entries %}
+ {% for entries in gl %}
| {{ loop.index }} |
{{ entries.account }} |
diff --git a/erpnext/controllers/accounts_controller.py b/erpnext/controllers/accounts_controller.py
index 7bb71ec9b52..63ea2591c5e 100644
--- a/erpnext/controllers/accounts_controller.py
+++ b/erpnext/controllers/accounts_controller.py
@@ -119,12 +119,6 @@ class AccountsController(TransactionBase):
self.validate_non_invoice_documents_schedule()
def before_print(self):
- if self.doctype in ['Journal Entry', 'Payment Entry', 'Sales Invoice', 'Purchase Invoice']:
- self.gl_entries = frappe.get_list("GL Entry", filters={
- "voucher_type": self.doctype,
- "voucher_no": self.name
- }, fields=["account", "party_type", "party", "debit", "credit", "remarks"])
-
if self.doctype in ['Purchase Order', 'Sales Order', 'Sales Invoice', 'Purchase Invoice',
'Supplier Quotation', 'Purchase Receipt', 'Delivery Note', 'Quotation']:
if self.get("group_same_items"):