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" |
shreyas | 6f8dfa4 | 2016-03-07 18:22:40 +0530 | [diff] [blame] | 19 | doc.flags.compact_item_fields = ["description", "qty", "rate", "amount"] |
robert schouten | 67eff49 | 2017-01-25 08:20:43 +0800 | [diff] [blame] | 20 | doc.flags.format_columns = format_columns |
shreyas | 6f8dfa4 | 2016-03-07 18:22:40 +0530 | [diff] [blame] | 21 | |
robert schouten | 67eff49 | 2017-01-25 08:20:43 +0800 | [diff] [blame] | 22 | def format_columns(display_columns, compact_fields): |
| 23 | compact_fields = compact_fields + ["image", "item_code", "item_name"] |
| 24 | final_columns = [] |
| 25 | for column in display_columns: |
| 26 | if column not in compact_fields: |
| 27 | final_columns.append(column) |
| 28 | return final_columns |