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 | |
prssanna | 71e5b60 | 2020-10-29 14:19:34 +0530 | [diff] [blame] | 8 | def set_print_templates_for_item_table(doc, settings): |
Rushabh Mehta | 0e13221 | 2015-02-04 17:02:24 +0530 | [diff] [blame] | 9 | doc.print_templates = { |
prssanna | 71e5b60 | 2020-10-29 14:19:34 +0530 | [diff] [blame] | 10 | "items": "templates/print_formats/includes/items.html", |
Rushabh Mehta | 0e13221 | 2015-02-04 17:02:24 +0530 | [diff] [blame] | 11 | } |
ShashaQin | 429ab20 | 2016-02-09 16:45:51 +0800 | [diff] [blame] | 12 | |
prssanna | 71e5b60 | 2020-10-29 14:19:34 +0530 | [diff] [blame] | 13 | doc.child_print_templates = { |
| 14 | "items": { |
| 15 | "qty": "templates/print_formats/includes/item_table_qty.html", |
| 16 | } |
| 17 | } |
ShashaQin | 429ab20 | 2016-02-09 16:45:51 +0800 | [diff] [blame] | 18 | |
prssanna | 71e5b60 | 2020-10-29 14:19:34 +0530 | [diff] [blame] | 19 | if doc.meta.get_field("items"): |
| 20 | doc.meta.get_field("items").hide_in_print_layout = ["uom", "stock_uom"] |
| 21 | |
| 22 | doc.flags.compact_item_fields = ["description", "qty", "rate", "amount"] |
| 23 | |
| 24 | if settings.compact_item_print: |
| 25 | doc.child_print_templates["items"]["description"] =\ |
| 26 | "templates/print_formats/includes/item_table_description.html" |
robert schouten | 67eff49 | 2017-01-25 08:20:43 +0800 | [diff] [blame] | 27 | doc.flags.format_columns = format_columns |
shreyas | 6f8dfa4 | 2016-03-07 18:22:40 +0530 | [diff] [blame] | 28 | |
prssanna | 71e5b60 | 2020-10-29 14:19:34 +0530 | [diff] [blame] | 29 | def set_print_templates_for_taxes(doc, settings): |
prssanna | b57b3c9 | 2020-10-22 15:37:47 +0530 | [diff] [blame] | 30 | doc.flags.show_inclusive_tax_in_print = doc.is_inclusive_tax() |
prssanna | 71e5b60 | 2020-10-29 14:19:34 +0530 | [diff] [blame] | 31 | doc.print_templates.update({ |
prssanna | b57b3c9 | 2020-10-22 15:37:47 +0530 | [diff] [blame] | 32 | "total": "templates/print_formats/includes/total.html", |
| 33 | "taxes": "templates/print_formats/includes/taxes.html" |
prssanna | 71e5b60 | 2020-10-29 14:19:34 +0530 | [diff] [blame] | 34 | }) |
prssanna | 13c6e2f | 2020-10-22 17:19:00 +0530 | [diff] [blame] | 35 | |
robert schouten | 67eff49 | 2017-01-25 08:20:43 +0800 | [diff] [blame] | 36 | def format_columns(display_columns, compact_fields): |
| 37 | compact_fields = compact_fields + ["image", "item_code", "item_name"] |
| 38 | final_columns = [] |
| 39 | for column in display_columns: |
| 40 | if column not in compact_fields: |
| 41 | final_columns.append(column) |
| 42 | return final_columns |