From bc6a2b2f9c260b2073ed2195d3147289664389f1 Mon Sep 17 00:00:00 2001 From: Faris Ansari Date: Tue, 27 Oct 2020 19:42:58 +0530 Subject: [PATCH] wip --- erpnext/controllers/buying_controller.py | 8 +++++ erpnext/controllers/print_settings.py | 14 +++----- erpnext/controllers/selling_controller.py | 11 +++++++ .../print_formats/includes/items.html | 33 +++++++++++++++++++ 4 files changed, 57 insertions(+), 9 deletions(-) create mode 100644 erpnext/templates/print_formats/includes/items.html diff --git a/erpnext/controllers/buying_controller.py b/erpnext/controllers/buying_controller.py index de04abbca4..596f6f4b57 100644 --- a/erpnext/controllers/buying_controller.py +++ b/erpnext/controllers/buying_controller.py @@ -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, diff --git a/erpnext/controllers/print_settings.py b/erpnext/controllers/print_settings.py index 5c29556398..418d8eb328 100644 --- a/erpnext/controllers/print_settings.py +++ b/erpnext/controllers/print_settings.py @@ -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' } } diff --git a/erpnext/controllers/selling_controller.py b/erpnext/controllers/selling_controller.py index ac26d3fea8..4c87e8c2f6 100644 --- a/erpnext/controllers/selling_controller.py +++ b/erpnext/controllers/selling_controller.py @@ -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, diff --git a/erpnext/templates/print_formats/includes/items.html b/erpnext/templates/print_formats/includes/items.html new file mode 100644 index 0000000000..933ae17c2a --- /dev/null +++ b/erpnext/templates/print_formats/includes/items.html @@ -0,0 +1,33 @@ +{%- if data -%} + {%- set visible_columns = get_visible_columns(doc.get(df.fieldname), + table_meta, df) -%} + +
+ + + + + {% 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 %} + + {% endif %} + {% endfor %} + + + + {% for d in data %} + + + {% 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 %} + + {% endif %} + {% endfor %} + + {% endfor %} + +
{{ _("Sr") }} + {{ _(tdf.label) }}
{{ d.idx }} +
{{ print_value(tdf, d, doc, visible_columns) }}
+
+{%- endif -%}