mirror of
https://github.com/frappe/erpnext.git
synced 2026-06-02 11:49:10 +00:00
feat: hook to fetch additional print settings in print view
This commit is contained in:
@@ -13,6 +13,7 @@ from erpnext.stock.stock_ledger import get_valuation_rate
|
|||||||
from erpnext.stock.doctype.stock_entry.stock_entry import get_used_alternative_items
|
from erpnext.stock.doctype.stock_entry.stock_entry import get_used_alternative_items
|
||||||
from erpnext.stock.doctype.serial_no.serial_no import get_auto_serial_nos, auto_make_serial_nos, get_serial_nos
|
from erpnext.stock.doctype.serial_no.serial_no import get_auto_serial_nos, auto_make_serial_nos, get_serial_nos
|
||||||
from frappe.contacts.doctype.address.address import get_address_display
|
from frappe.contacts.doctype.address.address import get_address_display
|
||||||
|
from erpnext.controllers.print_settings import print_settings_for_taxes
|
||||||
|
|
||||||
from erpnext.accounts.doctype.budget.budget import validate_expense_against_budget
|
from erpnext.accounts.doctype.budget.budget import validate_expense_against_budget
|
||||||
from erpnext.controllers.stock_controller import StockController
|
from erpnext.controllers.stock_controller import StockController
|
||||||
@@ -20,14 +21,7 @@ from erpnext.controllers.stock_controller import StockController
|
|||||||
class BuyingController(StockController):
|
class BuyingController(StockController):
|
||||||
def __setup__(self):
|
def __setup__(self):
|
||||||
if hasattr(self, "taxes"):
|
if hasattr(self, "taxes"):
|
||||||
self.flags.print_taxes_with_zero_amount = cint(frappe.db.get_single_value("Print Settings",
|
print_settings_for_taxes(self)
|
||||||
"print_taxes_with_zero_amount"))
|
|
||||||
self.flags.show_inclusive_tax_in_print = self.is_inclusive_tax()
|
|
||||||
|
|
||||||
self.print_templates = {
|
|
||||||
"total": "templates/print_formats/includes/total.html",
|
|
||||||
"taxes": "templates/print_formats/includes/taxes.html"
|
|
||||||
}
|
|
||||||
|
|
||||||
def get_feed(self):
|
def get_feed(self):
|
||||||
if self.get("supplier_name"):
|
if self.get("supplier_name"):
|
||||||
|
|||||||
@@ -5,20 +5,31 @@ from __future__ import unicode_literals
|
|||||||
import frappe
|
import frappe
|
||||||
from frappe.utils import cint
|
from frappe.utils import cint
|
||||||
|
|
||||||
def print_settings_for_item_table(doc):
|
def print_settings_for_item_table(doc, setting_value=None):
|
||||||
|
|
||||||
doc.print_templates = {
|
doc.print_templates = {
|
||||||
"qty": "templates/print_formats/includes/item_table_qty.html"
|
"qty": "templates/print_formats/includes/item_table_qty.html"
|
||||||
}
|
}
|
||||||
doc.hide_in_print_layout = ["uom", "stock_uom"]
|
doc.hide_in_print_layout = ["uom", "stock_uom"]
|
||||||
|
|
||||||
doc.flags.compact_item_print = cint(frappe.db.get_single_value("Print Settings", "compact_item_print"))
|
doc.flags.compact_item_print = setting_value if setting_value is not None\
|
||||||
|
else cint(frappe.db.get_single_value("Print Settings", "compact_item_print"))
|
||||||
|
|
||||||
if doc.flags.compact_item_print:
|
if doc.flags.compact_item_print:
|
||||||
doc.print_templates["description"] = "templates/print_formats/includes/item_table_description.html"
|
doc.print_templates["description"] = "templates/print_formats/includes/item_table_description.html"
|
||||||
doc.flags.compact_item_fields = ["description", "qty", "rate", "amount"]
|
doc.flags.compact_item_fields = ["description", "qty", "rate", "amount"]
|
||||||
doc.flags.format_columns = format_columns
|
doc.flags.format_columns = format_columns
|
||||||
|
|
||||||
|
def print_settings_for_taxes(doc, setting_value=None):
|
||||||
|
doc.flags.print_taxes_with_zero_amount = setting_value if setting_value is not None\
|
||||||
|
else cint(frappe.db.get_single_value("Print Settings", "print_taxes_with_zero_amount"))
|
||||||
|
doc.flags.show_inclusive_tax_in_print = doc.is_inclusive_tax()
|
||||||
|
|
||||||
|
doc.print_templates = {
|
||||||
|
"total": "templates/print_formats/includes/total.html",
|
||||||
|
"taxes": "templates/print_formats/includes/taxes.html"
|
||||||
|
}
|
||||||
|
|
||||||
def format_columns(display_columns, compact_fields):
|
def format_columns(display_columns, compact_fields):
|
||||||
compact_fields = compact_fields + ["image", "item_code", "item_name"]
|
compact_fields = compact_fields + ["image", "item_code", "item_name"]
|
||||||
final_columns = []
|
final_columns = []
|
||||||
@@ -26,3 +37,38 @@ def format_columns(display_columns, compact_fields):
|
|||||||
if column not in compact_fields:
|
if column not in compact_fields:
|
||||||
final_columns.append(column)
|
final_columns.append(column)
|
||||||
return final_columns
|
return final_columns
|
||||||
|
|
||||||
|
@frappe.whitelist()
|
||||||
|
def show_compact_item_setting(doc):
|
||||||
|
meta = frappe.get_meta(doc.doctype)
|
||||||
|
items_field = meta.get_field('items')
|
||||||
|
if items_field and items_field.fieldtype == 'Table':
|
||||||
|
return True
|
||||||
|
return False
|
||||||
|
|
||||||
|
@frappe.whitelist()
|
||||||
|
def show_taxes_setting(doc):
|
||||||
|
meta = frappe.get_meta(doc.doctype)
|
||||||
|
items_field = meta.get_field('taxes')
|
||||||
|
if items_field and items_field.fieldtype == 'Table':
|
||||||
|
return True
|
||||||
|
return False
|
||||||
|
|
||||||
|
def get_print_settings():
|
||||||
|
settings = {
|
||||||
|
'compact_item_print': {
|
||||||
|
'condition': 'erpnext.controllers.print_settings.show_compact_item_setting',
|
||||||
|
'fieldtype': 'Check',
|
||||||
|
'child_field': 'items',
|
||||||
|
'label': 'Compact Item Print',
|
||||||
|
'set_template': 'erpnext.controllers.print_settings.print_settings_for_item_table'
|
||||||
|
},
|
||||||
|
'print_taxes_with_zero_amount': {
|
||||||
|
'condition': 'erpnext.controllers.print_settings.show_taxes_setting',
|
||||||
|
'fieldtype': 'Check',
|
||||||
|
'label': 'Print taxes with zero amount',
|
||||||
|
'set_template': 'erpnext.controllers.print_settings.print_settings_for_taxes'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return settings
|
||||||
|
|||||||
@@ -11,20 +11,15 @@ from erpnext.stock.get_item_details import get_conversion_factor
|
|||||||
from erpnext.stock.doctype.item.item import set_item_default
|
from erpnext.stock.doctype.item.item import set_item_default
|
||||||
from frappe.contacts.doctype.address.address import get_address_display
|
from frappe.contacts.doctype.address.address import get_address_display
|
||||||
from erpnext.controllers.accounts_controller import get_taxes_and_charges
|
from erpnext.controllers.accounts_controller import get_taxes_and_charges
|
||||||
|
from erpnext.controllers.print_settings import print_settings_for_taxes
|
||||||
|
|
||||||
from erpnext.controllers.stock_controller import StockController
|
from erpnext.controllers.stock_controller import StockController
|
||||||
|
|
||||||
class SellingController(StockController):
|
class SellingController(StockController):
|
||||||
def __setup__(self):
|
def __setup__(self):
|
||||||
if hasattr(self, "taxes"):
|
if hasattr(self, "taxes"):
|
||||||
self.flags.print_taxes_with_zero_amount = cint(frappe.db.get_single_value("Print Settings",
|
print_settings_for_taxes(self)
|
||||||
"print_taxes_with_zero_amount"))
|
|
||||||
self.flags.show_inclusive_tax_in_print = self.is_inclusive_tax()
|
|
||||||
|
|
||||||
self.print_templates = {
|
|
||||||
"total": "templates/print_formats/includes/total.html",
|
|
||||||
"taxes": "templates/print_formats/includes/taxes.html"
|
|
||||||
}
|
|
||||||
|
|
||||||
def get_feed(self):
|
def get_feed(self):
|
||||||
return _("To {0} | {1} {2}").format(self.customer_name, self.currency,
|
return _("To {0} | {1} {2}").format(self.customer_name, self.currency,
|
||||||
|
|||||||
@@ -41,6 +41,7 @@ notification_config = "erpnext.startup.notifications.get_notification_config"
|
|||||||
get_help_messages = "erpnext.utilities.activation.get_help_messages"
|
get_help_messages = "erpnext.utilities.activation.get_help_messages"
|
||||||
leaderboards = "erpnext.startup.leaderboard.get_leaderboards"
|
leaderboards = "erpnext.startup.leaderboard.get_leaderboards"
|
||||||
filters_config = "erpnext.startup.filters.get_filters_config"
|
filters_config = "erpnext.startup.filters.get_filters_config"
|
||||||
|
additional_print_settings = "erpnext.controllers.print_settings.get_print_settings"
|
||||||
|
|
||||||
on_session_creation = [
|
on_session_creation = [
|
||||||
"erpnext.portal.utils.create_customer_or_supplier",
|
"erpnext.portal.utils.create_customer_or_supplier",
|
||||||
|
|||||||
@@ -2,13 +2,13 @@
|
|||||||
import frappe
|
import frappe
|
||||||
|
|
||||||
def get_filters_config():
|
def get_filters_config():
|
||||||
filters_config = {
|
filters_config = {
|
||||||
"fiscal year": {
|
"fiscal year": {
|
||||||
"label": "Fiscal Year",
|
"label": "Fiscal Year",
|
||||||
"get_field": "erpnext.accounts.utils.get_fiscal_year_filter_field",
|
"get_field": "erpnext.accounts.utils.get_fiscal_year_filter_field",
|
||||||
"valid_for_fieldtypes": ["Date", "Datetime", "DateRange"],
|
"valid_for_fieldtypes": ["Date", "Datetime", "DateRange"],
|
||||||
"depends_on": "company",
|
"depends_on": "company",
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return filters_config
|
return filters_config
|
||||||
Reference in New Issue
Block a user