Anand Doshi | 885e074 | 2015-03-03 14:55:30 +0530 | [diff] [blame] | 1 | # Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors |
Rushabh Mehta | 0e13221 | 2015-02-04 17:02:24 +0530 | [diff] [blame] | 2 | # License: GNU General Public License v3. See license.txt |
| 3 | |
ShashaQin | 429ab20 | 2016-02-09 16:45:51 +0800 | [diff] [blame] | 4 | from __future__ import unicode_literals |
| 5 | import frappe |
| 6 | from frappe.utils import cint |
| 7 | |
Rushabh Mehta | 0e13221 | 2015-02-04 17:02:24 +0530 | [diff] [blame] | 8 | def print_settings_for_item_table(doc): |
ShashaQin | 429ab20 | 2016-02-09 16:45:51 +0800 | [diff] [blame] | 9 | |
Rushabh Mehta | 0e13221 | 2015-02-04 17:02:24 +0530 | [diff] [blame] | 10 | doc.print_templates = { |
| 11 | "description": "templates/print_formats/includes/item_table_description.html", |
| 12 | "qty": "templates/print_formats/includes/item_table_qty.html" |
| 13 | } |
ShashaQin | fd08750 | 2016-02-12 09:22:05 +0800 | [diff] [blame] | 14 | compact_item_view = cint(frappe.db.get_value("Features Setup", None, "compact_item_view")) |
ShashaQin | 429ab20 | 2016-02-09 16:45:51 +0800 | [diff] [blame] | 15 | |
Rushabh Mehta | 0e13221 | 2015-02-04 17:02:24 +0530 | [diff] [blame] | 16 | doc.hide_in_print_layout = ["item_code", "item_name", "image", "uom", "stock_uom"] |
ShashaQin | 429ab20 | 2016-02-09 16:45:51 +0800 | [diff] [blame] | 17 | |
| 18 | std_fields = ["item_code", "item_name", "description", "qty", "rate", "amount", "stock_uom", "uom"] |
| 19 | |
ShashaQin | fd08750 | 2016-02-12 09:22:05 +0800 | [diff] [blame] | 20 | if compact_item_view: |
ShashaQin | 429ab20 | 2016-02-09 16:45:51 +0800 | [diff] [blame] | 21 | |
| 22 | for df in doc.meta.fields: |
| 23 | if df.fieldtype not in ("Section Break", "Column Break", "Button"): |
| 24 | if not doc.is_print_hide(df.fieldname): |
| 25 | if df.fieldname not in doc.hide_in_print_layout and df.fieldname not in std_fields: |
| 26 | doc.hide_in_print_layout.append(df.fieldname) |
| 27 | |
| 28 | |