diff --git a/erpnext/stock/doctype/delivery_note/delivery_note.py b/erpnext/stock/doctype/delivery_note/delivery_note.py index 13da9078b01..54e4fa2acb7 100644 --- a/erpnext/stock/doctype/delivery_note/delivery_note.py +++ b/erpnext/stock/doctype/delivery_note/delivery_note.py @@ -40,6 +40,20 @@ class DeliveryNote(SellingController): total_qty = sum((item.qty for item in self.get("delivery_note_details"))) self.get("__onload").billing_complete = (billed_qty[0][0] == total_qty) + def before_print(self): + def toggle_print_hide(meta, fieldname): + df = meta.get_field(fieldname) + if self.get("print_without_amount"): + df.set("__print_hide", 1) + else: + df.delete_key("__print_hide") + + toggle_print_hide(self.meta, "currency") + + item_meta = frappe.get_meta("Delivery Note Item") + for fieldname in ("rate", "amount", "price_list_rate", "discount_percentage"): + toggle_print_hide(item_meta, fieldname) + def get_portal_page(self): return "shipment" if self.docstatus==1 else None diff --git a/erpnext/templates/print_formats/includes/item_grid.html b/erpnext/templates/print_formats/includes/item_grid.html index 63885c0ae4b..3cc3034f3a0 100644 --- a/erpnext/templates/print_formats/includes/item_grid.html +++ b/erpnext/templates/print_formats/includes/item_grid.html @@ -1,6 +1,8 @@ {%- from "templates/print_formats/standard_macros.html" import print_value -%} {%- set std_fields = ("item_code", "item_name", "description", "qty", "rate", "amount", "stock_uom", "uom") -%} {%- set visible_columns = get_visible_columns(doc.get(df.fieldname), table_meta) -%} +{%- set hide_rate = data[0].meta.is_print_hide("rate") -%} +{%- set hide_amount = data[0].meta.is_print_hide("amount") -%}
| {{ _("Sr") }} | {{ _("Item") }} | {{ _("Qty") }} | -{{ _("Rate") }} | -{{ _("Amount") }} | + {% if not hide_rate -%}{{ _("Rate") }} | {%- endif %} + {% if not hide_amount -%}{{ _("Amount") }} | {%- endif %} {%- for row in data -%}
|---|---|---|---|---|
| {{ row.get_formatted("qty", doc) }} {{ row.uom or row.stock_uom }} |
- {{ - row.get_formatted("rate", doc) }} | -{{ - row.get_formatted("amount", doc) }} | + {% if not hide_rate -%}{{ row.get_formatted("rate", doc) }} | {%- endif %} + {% if not hide_amount -%}{{ row.get_formatted("amount", doc) }} | {%- endif %}