[print] Hide Rate, Amount if Print Without Amount in Delivery Note

This commit is contained in:
Anand Doshi 2014-07-29 21:58:39 +05:30
parent a12312553b
commit 0e93352c8d
2 changed files with 22 additions and 8 deletions

View File

@ -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

View File

@ -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") -%}
<table class="table table-bordered">
<tbody>
@ -8,8 +10,8 @@
<th style="width: 3%">{{ _("Sr") }}</th>
<th style="width: 57%">{{ _("Item") }}</th>
<th style="width: 10%;" class="text-right">{{ _("Qty") }}</th>
<th style="width: 15%;" class="text-right">{{ _("Rate") }}</th>
<th style="width: 15%;" class="text-right">{{ _("Amount") }}</th>
{% if not hide_rate -%}<th style="width: 15%;" class="text-right">{{ _("Rate") }}</th>{%- endif %}
{% if not hide_amount -%}<th style="width: 15%;" class="text-right">{{ _("Amount") }}</th>{%- endif %}
</tr>
{%- for row in data -%}
<tr>
@ -30,17 +32,15 @@
{%- for field in visible_columns -%}
{%- if (field.fieldname not in std_fields) and
(row[field.fieldname] not in (None, "", 0)) -%}
<div><strong>{{ _(field.label) }}:</strong></div>
{{ row.get_formatted(field.fieldname, doc) }}
<div><strong>{{ _(field.label) }}:</strong>
{{ row.get_formatted(field.fieldname, doc) }}</div>
{%- endif -%}
{%- endfor -%}
</td>
<td style="text-align: right;">{{ row.get_formatted("qty", doc) }}<br>
<small>{{ row.uom or row.stock_uom }}</small></td>
<td style="text-align: right;">{{
row.get_formatted("rate", doc) }}</td>
<td style="text-align: right;">{{
row.get_formatted("amount", doc) }}</td>
{% if not hide_rate -%}<td style="text-align: right;">{{ row.get_formatted("rate", doc) }}</td>{%- endif %}
{% if not hide_amount -%}<td style="text-align: right;">{{ row.get_formatted("amount", doc) }}</td>{%- endif %}
</tr>
{%- endfor -%}
</tbody>