diff --git a/erpnext/controllers/print_settings.py b/erpnext/controllers/print_settings.py index 7c00e64529..bc34f7c6b3 100644 --- a/erpnext/controllers/print_settings.py +++ b/erpnext/controllers/print_settings.py @@ -6,23 +6,24 @@ import frappe from frappe.utils import cint def print_settings_for_item_table(doc): - + doc.print_templates = { "description": "templates/print_formats/includes/item_table_description.html", "qty": "templates/print_formats/includes/item_table_qty.html" } - compact_item_view = cint(frappe.db.get_value("Features Setup", None, "compact_item_view")) - + doc.hide_in_print_layout = ["item_code", "item_name", "image", "uom", "stock_uom"] - std_fields = ["item_code", "item_name", "description", "qty", "rate", "amount", "stock_uom", "uom"] + doc.flags.compact_item_print = cint(frappe.db.get_value("Features Setup", None, "compact_item_print")) + doc.flags.compact_item_fields = doc.hide_in_print_layout + ["description", "qty", "rate", "amount"] + doc.flags.show_in_description = [] - if compact_item_view: - + if doc.flags.compact_item_print: for df in doc.meta.fields: if df.fieldtype not in ("Section Break", "Column Break", "Button"): if not doc.is_print_hide(df.fieldname): - if df.fieldname not in doc.hide_in_print_layout and df.fieldname not in std_fields: + if df.fieldname not in doc.hide_in_print_layout and df.fieldname not in doc.flags.compact_item_fields: doc.hide_in_print_layout.append(df.fieldname) + doc.flags.show_in_description.append(df.fieldname) diff --git a/erpnext/setup/doctype/features_setup/features_setup.js b/erpnext/setup/doctype/features_setup/features_setup.js new file mode 100644 index 0000000000..a637a8e785 --- /dev/null +++ b/erpnext/setup/doctype/features_setup/features_setup.js @@ -0,0 +1,5 @@ +frappe.ui.form.on('Features Setup', { + refresh: function(frm) { + + } +}); diff --git a/erpnext/setup/doctype/features_setup/features_setup.json b/erpnext/setup/doctype/features_setup/features_setup.json index 6db3132d38..8dea339817 100644 --- a/erpnext/setup/doctype/features_setup/features_setup.json +++ b/erpnext/setup/doctype/features_setup/features_setup.json @@ -18,9 +18,11 @@ "in_filter": 0, "in_list_view": 0, "label": "Materials", + "length": 0, "no_copy": 0, "permlevel": 0, "print_hide": 0, + "print_hide_if_no_value": 0, "read_only": 0, "report_hide": 0, "reqd": 0, @@ -40,9 +42,11 @@ "in_filter": 0, "in_list_view": 1, "label": "Item Serial Nos", + "length": 0, "no_copy": 0, "permlevel": 0, "print_hide": 0, + "print_hide_if_no_value": 0, "read_only": 0, "report_hide": 0, "reqd": 0, @@ -62,9 +66,11 @@ "in_filter": 0, "in_list_view": 1, "label": "Item Batch Nos", + "length": 0, "no_copy": 0, "permlevel": 0, "print_hide": 0, + "print_hide_if_no_value": 0, "read_only": 0, "report_hide": 0, "reqd": 0, @@ -84,9 +90,11 @@ "in_filter": 0, "in_list_view": 1, "label": "Brands", + "length": 0, "no_copy": 0, "permlevel": 0, "print_hide": 0, + "print_hide_if_no_value": 0, "read_only": 0, "report_hide": 0, "reqd": 0, @@ -106,9 +114,11 @@ "in_filter": 0, "in_list_view": 1, "label": "Item Barcode", + "length": 0, "no_copy": 0, "permlevel": 0, "print_hide": 0, + "print_hide_if_no_value": 0, "read_only": 0, "report_hide": 0, "reqd": 0, @@ -126,9 +136,11 @@ "ignore_user_permissions": 0, "in_filter": 0, "in_list_view": 0, + "length": 0, "no_copy": 0, "permlevel": 0, "print_hide": 0, + "print_hide_if_no_value": 0, "read_only": 0, "report_hide": 0, "reqd": 0, @@ -140,7 +152,7 @@ "allow_on_submit": 0, "bold": 0, "collapsible": 0, - "description": "1. To maintain the customer wise item code and to make them searchable based on their code use this option", + "description": "To maintain the customer wise item code and to make them searchable based on their code use this option", "fieldname": "fs_item_advanced", "fieldtype": "Check", "hidden": 0, @@ -148,9 +160,11 @@ "in_filter": 0, "in_list_view": 0, "label": "Item Advanced", + "length": 0, "no_copy": 0, "permlevel": 0, "print_hide": 0, + "print_hide_if_no_value": 0, "read_only": 0, "report_hide": 0, "reqd": 0, @@ -170,9 +184,11 @@ "in_filter": 0, "in_list_view": 0, "label": "Item Groups in Details", + "length": 0, "no_copy": 0, "permlevel": 0, "print_hide": 0, + "print_hide_if_no_value": 0, "read_only": 0, "report_hide": 0, "reqd": 0, @@ -184,14 +200,14 @@ "allow_on_submit": 0, "bold": 0, "collapsible": 0, - "description": "if checked, only 5 columns are shown in print preview. Any extra field is shown under 'Description' column.", - "fieldname": "compact_item_view", + "description": "If checked, only Description, Quantity, Rate and Amount are shown in print of Item table. Any extra field is shown under 'Description' column.", + "fieldname": "compact_item_print", "fieldtype": "Check", "hidden": 0, "ignore_user_permissions": 0, "in_filter": 0, "in_list_view": 0, - "label": "Compact Item View", + "label": "Compact Item Print", "length": 0, "no_copy": 0, "permlevel": 0, @@ -204,7 +220,7 @@ "search_index": 0, "set_only_once": 0, "unique": 0 - }, + }, { "allow_on_submit": 0, "bold": 0, @@ -216,9 +232,11 @@ "in_filter": 0, "in_list_view": 0, "label": "Sales and Purchase", + "length": 0, "no_copy": 0, "permlevel": 0, "print_hide": 0, + "print_hide_if_no_value": 0, "read_only": 0, "report_hide": 0, "reqd": 0, @@ -238,9 +256,11 @@ "in_filter": 0, "in_list_view": 0, "label": "Exports", + "length": 0, "no_copy": 0, "permlevel": 0, "print_hide": 0, + "print_hide_if_no_value": 0, "read_only": 0, "report_hide": 0, "reqd": 0, @@ -260,9 +280,11 @@ "in_filter": 0, "in_list_view": 0, "label": "Imports", + "length": 0, "no_copy": 0, "permlevel": 0, "print_hide": 0, + "print_hide_if_no_value": 0, "read_only": 0, "report_hide": 0, "reqd": 0, @@ -280,9 +302,11 @@ "ignore_user_permissions": 0, "in_filter": 0, "in_list_view": 0, + "length": 0, "no_copy": 0, "permlevel": 0, "print_hide": 0, + "print_hide_if_no_value": 0, "read_only": 0, "report_hide": 0, "reqd": 0, @@ -302,9 +326,11 @@ "in_filter": 0, "in_list_view": 0, "label": "Sales Discounts", + "length": 0, "no_copy": 0, "permlevel": 0, "print_hide": 0, + "print_hide_if_no_value": 0, "read_only": 0, "report_hide": 0, "reqd": 0, @@ -324,9 +350,11 @@ "in_filter": 0, "in_list_view": 0, "label": "Purchase Discounts", + "length": 0, "no_copy": 0, "permlevel": 0, "print_hide": 0, + "print_hide_if_no_value": 0, "read_only": 0, "report_hide": 0, "reqd": 0, @@ -346,9 +374,11 @@ "in_filter": 0, "in_list_view": 0, "label": "After Sale Installations", + "length": 0, "no_copy": 0, "permlevel": 0, "print_hide": 0, + "print_hide_if_no_value": 0, "read_only": 0, "report_hide": 0, "reqd": 0, @@ -368,9 +398,11 @@ "in_filter": 0, "in_list_view": 0, "label": "Projects", + "length": 0, "no_copy": 0, "permlevel": 0, "print_hide": 0, + "print_hide_if_no_value": 0, "read_only": 0, "report_hide": 0, "reqd": 0, @@ -390,9 +422,11 @@ "in_filter": 0, "in_list_view": 0, "label": "Sales Extras", + "length": 0, "no_copy": 0, "permlevel": 0, "print_hide": 0, + "print_hide_if_no_value": 0, "read_only": 0, "report_hide": 0, "reqd": 0, @@ -411,9 +445,11 @@ "in_filter": 0, "in_list_view": 0, "label": "Accounts", + "length": 0, "no_copy": 0, "permlevel": 0, "print_hide": 0, + "print_hide_if_no_value": 0, "read_only": 0, "report_hide": 0, "reqd": 0, @@ -433,9 +469,11 @@ "in_filter": 0, "in_list_view": 0, "label": "Recurring Invoice", + "length": 0, "no_copy": 0, "permlevel": 0, "print_hide": 0, + "print_hide_if_no_value": 0, "read_only": 0, "report_hide": 0, "reqd": 0, @@ -453,9 +491,11 @@ "ignore_user_permissions": 0, "in_filter": 0, "in_list_view": 0, + "length": 0, "no_copy": 0, "permlevel": 0, "print_hide": 0, + "print_hide_if_no_value": 0, "read_only": 0, "report_hide": 0, "reqd": 0, @@ -475,9 +515,11 @@ "in_filter": 0, "in_list_view": 0, "label": "Point of Sale", + "length": 0, "no_copy": 0, "permlevel": 0, "print_hide": 0, + "print_hide_if_no_value": 0, "read_only": 0, "report_hide": 0, "reqd": 0, @@ -497,9 +539,11 @@ "in_filter": 0, "in_list_view": 0, "label": "POS View", + "length": 0, "no_copy": 0, "permlevel": 0, "print_hide": 0, + "print_hide_if_no_value": 0, "read_only": 0, "report_hide": 0, "reqd": 0, @@ -518,9 +562,11 @@ "in_filter": 0, "in_list_view": 0, "label": "Manufacturing", + "length": 0, "no_copy": 0, "permlevel": 0, "print_hide": 0, + "print_hide_if_no_value": 0, "read_only": 0, "report_hide": 0, "reqd": 0, @@ -540,9 +586,11 @@ "in_filter": 0, "in_list_view": 0, "label": "Manufacturing", + "length": 0, "no_copy": 0, "permlevel": 0, "print_hide": 0, + "print_hide_if_no_value": 0, "read_only": 0, "report_hide": 0, "reqd": 0, @@ -560,9 +608,11 @@ "ignore_user_permissions": 0, "in_filter": 0, "in_list_view": 0, + "length": 0, "no_copy": 0, "permlevel": 0, "print_hide": 0, + "print_hide_if_no_value": 0, "read_only": 0, "report_hide": 0, "reqd": 0, @@ -582,9 +632,11 @@ "in_filter": 0, "in_list_view": 0, "label": "Quality", + "length": 0, "no_copy": 0, "permlevel": 0, "print_hide": 0, + "print_hide_if_no_value": 0, "read_only": 0, "report_hide": 0, "reqd": 0, @@ -603,9 +655,11 @@ "in_filter": 0, "in_list_view": 0, "label": "Miscelleneous", + "length": 0, "no_copy": 0, "permlevel": 0, "print_hide": 0, + "print_hide_if_no_value": 0, "read_only": 0, "report_hide": 0, "reqd": 0, @@ -625,9 +679,11 @@ "in_filter": 0, "in_list_view": 0, "label": "Page Break", + "length": 0, "no_copy": 0, "permlevel": 0, "print_hide": 0, + "print_hide_if_no_value": 0, "read_only": 0, "report_hide": 0, "reqd": 0, @@ -645,9 +701,11 @@ "ignore_user_permissions": 0, "in_filter": 0, "in_list_view": 0, + "length": 0, "no_copy": 0, "permlevel": 0, "print_hide": 0, + "print_hide_if_no_value": 0, "read_only": 0, "report_hide": 0, "reqd": 0, @@ -666,9 +724,11 @@ "in_filter": 0, "in_list_view": 0, "label": "More Information", + "length": 0, "no_copy": 0, "permlevel": 0, "print_hide": 0, + "print_hide_if_no_value": 0, "read_only": 0, "report_hide": 0, "reqd": 0, @@ -686,7 +746,8 @@ "is_submittable": 0, "issingle": 1, "istable": 0, - "modified": "2016-02-12 08:53:48.982439", + "max_attachments": 0, + "modified": "2016-02-16 04:43:32.144944", "modified_by": "Administrator", "module": "Setup", "name": "Features Setup", @@ -735,5 +796,6 @@ } ], "read_only": 0, - "read_only_onload": 0 -} + "read_only_onload": 0, + "sort_order": "ASC" +} \ No newline at end of file diff --git a/erpnext/templates/print_formats/includes/item_table_description.html b/erpnext/templates/print_formats/includes/item_table_description.html index 2a6ef42dbf..a9f7bcce4a 100644 --- a/erpnext/templates/print_formats/includes/item_table_description.html +++ b/erpnext/templates/print_formats/includes/item_table_description.html @@ -1,38 +1,46 @@ -{%- set std_fields = ("item_code", "item_name", "description", "qty", "rate", "amount", "stock_uom", "uom") -%} -{%- set compact_item_view = frappe.utils.cint(frappe.db.get_value("Features Setup", None, "compact_item_view")) -%} +{%- set compact = doc.flags.compact_item_print -%} +{%- set compact_fields = doc.flags.compact_item_fields -%} {% if doc.in_format_data("image") and doc.get("image") and not doc.is_print_hide("image")-%}
{{ doc.get_formatted("description") }}
- {%- endif %} - {% if (compact_item_view == 1) -%} - {%- for field in doc.hide_in_print_layout -%} - {%- if (field not in std_fields) and - (doc.get(field) not in (None, "", 0)) -%} -{{ doc.get_formatted("description") }}
+ {%- endif %} + + {% if compact -%} + {%- for fieldname in doc.flags.show_in_description -%} + {% if doc.get(fieldname) -%} ++ {{ doc.meta.get_label(fieldname) }}: + {{ doc.get_formatted(fieldname) }} +
+ {% endif %} + {%- endfor -%} {%- endif %}