Skip to main content

PrintFormat

Print format configuration DocType.

Stores print template configuration for a DocType.

Attributes:
name: Display name for the format
doctype: Target DocType this format applies to
template: Path to Jinja2 template file
is_default: If True, this is the default format for the DocType
css: Optional custom CSS for styling
header_html: Optional custom header HTML
footer_html: Optional custom footer HTML
page_size: Page size for PDF (A4, Letter, etc.)
orientation: Page orientation (portrait, landscape)

Example:
format = PrintFormat(
name="Invoice Pro Forma",
doctype="Invoice",
template="invoice_proforma.html",
)

Source: print_format.py

Fields

FieldTypeRequiredDescriptionValidators
namestrDisplay name for the print formatminLen: 1, maxLen: 255
doctypestrTarget DocType this format applies tominLen: 1
templatestrPath to Jinja2 template fileminLen: 1
is_defaultboolIf True, this is the default format for the DocType-
cssstrNoneOptional custom CSS for styling
header_htmlstrNoneOptional custom header HTML
footer_htmlstrNoneOptional custom footer HTML
page_sizestrPage size for PDF (A4, Letter, Legal)pattern: `^(A4
orientationstrPage orientation (portrait, landscape)pattern: `^(portrait

Permissions

RoleCreateDeleteReadWrite
All
System Manager

Configuration

SettingValue
SubmittableFalse
Track ChangesTrue

Controller

Controller hooks are implemented in *_controller.py files. Available lifecycle hooks:

  • validate() - Called before save, raise exceptions for validation errors
  • before_insert() - Called before inserting a new document
  • after_insert() - Called after successfully inserting
  • before_save() - Called before saving (insert or update)
  • after_save() - Called after saving
  • before_delete() - Called before deleting
  • after_delete() - Called after deleting