blob: 25ae1b2d88b92b45a32131d4dcdfa639d4f300dc [file] [log] [blame]
Anand Doshi885e0742015-03-03 14:55:30 +05301# Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors
Rushabh Mehta0e132212015-02-04 17:02:24 +05302# License: GNU General Public License v3. See license.txt
3
ShashaQin429ab202016-02-09 16:45:51 +08004from __future__ import unicode_literals
5import frappe
6from frappe.utils import cint
7
Rushabh Mehta0e132212015-02-04 17:02:24 +05308def print_settings_for_item_table(doc):
Anand Doshi9a933782016-02-16 15:30:17 +05309
Rushabh Mehta0e132212015-02-04 17:02:24 +053010 doc.print_templates = {
Rushabh Mehta0e132212015-02-04 17:02:24 +053011 "qty": "templates/print_formats/includes/item_table_qty.html"
12 }
shreyas6f8dfa42016-03-07 18:22:40 +053013 doc.hide_in_print_layout = ["uom", "stock_uom"]
ShashaQin429ab202016-02-09 16:45:51 +080014
Rushabh Mehtad42167e2016-05-11 16:47:14 +053015 doc.flags.compact_item_print = cint(frappe.db.get_value("Print Settings", None, "compact_item_print"))
ShashaQin429ab202016-02-09 16:45:51 +080016
Anand Doshi9a933782016-02-16 15:30:17 +053017 if doc.flags.compact_item_print:
shreyas6f8dfa42016-03-07 18:22:40 +053018 doc.print_templates["description"] = "templates/print_formats/includes/item_table_description.html"
19 doc.hide_in_print_layout += ["item_code", "item_name", "image"]
20
21 doc.flags.compact_item_fields = ["description", "qty", "rate", "amount"]
22 doc.flags.show_in_description = []
23
ShashaQin429ab202016-02-09 16:45:51 +080024 for df in doc.meta.fields:
25 if df.fieldtype not in ("Section Break", "Column Break", "Button"):
26 if not doc.is_print_hide(df.fieldname):
Anand Doshi9a933782016-02-16 15:30:17 +053027 if df.fieldname not in doc.hide_in_print_layout and df.fieldname not in doc.flags.compact_item_fields:
ShashaQin429ab202016-02-09 16:45:51 +080028 doc.hide_in_print_layout.append(df.fieldname)
Anand Doshi9a933782016-02-16 15:30:17 +053029 doc.flags.show_in_description.append(df.fieldname)