This commit is contained in:
Faris Ansari 2020-10-27 19:42:58 +05:30 committed by prssanna
parent 13c6e2f320
commit bc6a2b2f9c
4 changed files with 57 additions and 9 deletions

View File

@ -23,6 +23,14 @@ class BuyingController(StockController):
if hasattr(self, "taxes"):
print_settings_for_taxes(self)
def before_print(self):
pass
def get_print_settings(self):
items_field = self.meta.get_field('items')
if items_field and items_field.fieldtype == 'Table':
return ['compact_item_print', 'print_uom_after_quantity']
def get_feed(self):
if self.get("supplier_name"):
return _("From {0} | {1} {2}").format(self.supplier_name, self.currency,

View File

@ -64,26 +64,22 @@ def has_taxes_field(doc):
return False
def get_print_settings():
# return ['comp']
settings = {
'compact_item_print': {
'condition': 'erpnext.controllers.print_settings.has_items_field',
'fieldtype': 'Check',
'child_field': 'items',
'label': 'Compact Item Print',
'set_template': 'erpnext.controllers.print_settings.print_settings_for_item_table'
# 'set_template': 'erpnext.controllers.print_settings.print_settings_for_item_table'
},
'print_uom_after_quantity': {
'condition': 'erpnext.controllers.print_settings.has_taxes_field',
'fieldtype': 'Check',
'child_field': 'items',
'label': 'Print UOM after Quantity',
'set_template': 'erpnext.controllers.print_settings.print_settings_for_item_table'
# 'set_template': 'erpnext.controllers.print_settings.print_settings_for_item_table'
},
'print_taxes_with_zero_amount': {
'condition': 'erpnext.controllers.print_settings.has_taxes_field',
'fieldtype': 'Check',
'label': 'Print taxes with zero amount',
'set_template': 'erpnext.controllers.print_settings.print_settings_for_taxes'
# 'set_template': 'erpnext.controllers.print_settings.print_settings_for_taxes'
}
}

View File

@ -20,6 +20,17 @@ class SellingController(StockController):
if hasattr(self, "taxes"):
print_settings_for_taxes(self)
def before_print(self):
self.print_templates = {
"items": "templates/print_formats/includes/items.html",
}
self.flags.compact_item_fields = ['description']
def get_print_settings(self):
items_field = self.meta.get_field('items')
if items_field and items_field.fieldtype == 'Table':
return ['compact_item_print', 'print_uom_after_quantity']
def get_feed(self):
return _("To {0} | {1} {2}").format(self.customer_name, self.currency,

View File

@ -0,0 +1,33 @@
{%- if data -%}
{%- set visible_columns = get_visible_columns(doc.get(df.fieldname),
table_meta, df) -%}
<div {{ fieldmeta(df) }}>
<table class="table table-bordered table-condensed">
<thead>
<tr>
<th style="width: 40px" class="table-sr">{{ _("Sr") }}</th>
{% for tdf in visible_columns %}
{% if (data and not print_settings.compact_item_print) or tdf.fieldname in doc.get(df.fieldname)[0].flags.compact_item_fields %}
<th style="width: {{ get_width(tdf) }};" class="{{ get_align_class(tdf) }}" {{ fieldmeta(df) }}>
{{ _(tdf.label) }}</th>
{% endif %}
{% endfor %}
</tr>
</thead>
<tbody>
{% for d in data %}
<tr>
<td class="table-sr">{{ d.idx }}</td>
{% for tdf in visible_columns %}
{% if not doc.get(df.fieldname)[0].flags.compact_item_print or tdf.fieldname in doc.get(df.fieldname)[0].flags.compact_item_fields %}
<td class="{{ get_align_class(tdf) }}" {{ fieldmeta(df) }}>
<div class="value">{{ print_value(tdf, d, doc, visible_columns) }}</div></td>
{% endif %}
{% endfor %}
</tr>
{% endfor %}
</tbody>
</table>
</div>
{%- endif -%}