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