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): |
Anand Doshi | 9a93378 | 2016-02-16 15:30:17 +0530 | [diff] [blame] | 9 | |
Rushabh Mehta | 0e13221 | 2015-02-04 17:02:24 +0530 | [diff] [blame] | 10 | doc.print_templates = { |
Rushabh Mehta | 0e13221 | 2015-02-04 17:02:24 +0530 | [diff] [blame] | 11 | "qty": "templates/print_formats/includes/item_table_qty.html" |
| 12 | } |
shreyas | 6f8dfa4 | 2016-03-07 18:22:40 +0530 | [diff] [blame] | 13 | doc.hide_in_print_layout = ["uom", "stock_uom"] |
ShashaQin | 429ab20 | 2016-02-09 16:45:51 +0800 | [diff] [blame] | 14 | |
Rushabh Mehta | d42167e | 2016-05-11 16:47:14 +0530 | [diff] [blame] | 15 | doc.flags.compact_item_print = cint(frappe.db.get_value("Print Settings", None, "compact_item_print")) |
ShashaQin | 429ab20 | 2016-02-09 16:45:51 +0800 | [diff] [blame] | 16 | |
Anand Doshi | 9a93378 | 2016-02-16 15:30:17 +0530 | [diff] [blame] | 17 | if doc.flags.compact_item_print: |
shreyas | 6f8dfa4 | 2016-03-07 18:22:40 +0530 | [diff] [blame] | 18 | 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 | |
ShashaQin | 429ab20 | 2016-02-09 16:45:51 +0800 | [diff] [blame] | 24 | 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 Doshi | 9a93378 | 2016-02-16 15:30:17 +0530 | [diff] [blame] | 27 | if df.fieldname not in doc.hide_in_print_layout and df.fieldname not in doc.flags.compact_item_fields: |
ShashaQin | 429ab20 | 2016-02-09 16:45:51 +0800 | [diff] [blame] | 28 | doc.hide_in_print_layout.append(df.fieldname) |
Anand Doshi | 9a93378 | 2016-02-16 15:30:17 +0530 | [diff] [blame] | 29 | doc.flags.show_in_description.append(df.fieldname) |