Print Settings docType is in frappe. How to add checkbox from code of erpnext?

I’m trying to share my modification in printing as configurable option for everyone (contribute to ERPNext, so anyone can use it).

The problem is that “Print Settings” docType is part of frappe/frappe repo, and controller deciding what will be printed is in frappe/erpnext repo.

For consistency reason, I would like to make changes only in erpnext.

If I add checkbox directly in frappe, it will be visible for every frappe user, even not using erpnext. So it’s not good solution.

In heavy details: controller sets:

doc.print_templates = { “qty”: “templates/print_formats/includes/item_table_qty.html” }

I want to make it optional and if some option is checked in Print Settings (let’s call it “Swap UOM and quantity”), other file will be used as qty template. For example:

if swap_uom_and_quantity != 1:
doc.print_templates = { “qty”: “templates/print_formats/includes/item_table_qty.html” } # standard
doc.print_templates = { “qty”: “templates/print_formats/includes/item_table_qty_swapped.html” } # alternative

So I added a checkbox in Print Settings, so user can switch alternative version on or off. And it works. But now checkbox is visible even if erpnext is not installed, so it has no sense.

Do you have any idea how to solve it?

In apps/erpnext/erpnext/setup/ there were 2 check boxes added to Print Settings after installation of ERPNext. I made it in the same way. So my check box will be added after installation of ERPNext.

def after_install():

def create_compact_item_print_custom_field():
create_custom_field(‘Print Settings’, {
‘label’: _(‘Compact Item Print’),
‘fieldname’: ‘compact_item_print’,
‘fieldtype’: ‘Check’,
‘default’: 1,
‘insert_after’: ‘with_letterhead’

def create_print_zero_amount_taxes_custom_field():
create_custom_field(‘Print Settings’, {
‘label’: _(‘Print taxes with zero amount’),
‘fieldname’: ‘print_taxes_with_zero_amount’,
‘fieldtype’: ‘Check’,
‘default’: 0,
‘insert_after’: ‘allow_print_for_cancelled’