brotherton-erpnext/erpnext/regional/germany/setup.py

32 lines
767 B
Python
Raw Normal View History

2019-02-07 02:28:27 +00:00
import os
import frappe
def setup(company=None, patch=True):
2019-02-07 02:28:27 +00:00
if not patch:
update_address_template()
def update_address_template():
2019-02-07 02:28:27 +00:00
"""
Read address template from file. Update existing Address Template or create a
new one.
"""
dir_name = os.path.dirname(__file__)
template_path = os.path.join(dir_name, 'address_template.html')
with open(template_path, 'r') as template_file:
template_html = template_file.read()
address_template = frappe.db.get_value('Address Template', 'Germany')
2019-02-07 02:28:27 +00:00
if address_template:
frappe.db.set_value('Address Template', 'Germany', 'template', template_html)
else:
# make new html template for Germany
frappe.get_doc(dict(
doctype='Address Template',
country='Germany',
template=template_html
)).insert()