forked from alyf-de/erpnext_druckformate
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathupdate.py
50 lines (40 loc) · 1.21 KB
/
update.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
import os
from getpass import getpass
from subprocess import run
from frappeclient import FrappeClient
ERPNEXT_URL = 'https://erp.alyf.cloud' # Bitte anpassen!
PRINT_STYLE_PATH = 'print_style/print_style'
PRINT_FORMATS = {
# 'Dateiname': 'Name des Print Format in ERPNext'
'quotation.html': 'Angebot', # Bitte anpassen!
'sales_invoice.html': 'Ausgangsrechnung', # Bitte anpassen!
'sales_order.html': 'Kundenauftrag' # Bitte anpassen!
}
def update_css():
input_path = PRINT_STYLE_PATH + '.scss'
output_path = PRINT_STYLE_PATH + '.css'
run(['sass', '--style=compressed', input_path, output_path], check=True)
return output_path
def main():
password = getpass()
username = input('Username: ')
css = None
css_path = update_css()
with open(css_path) as css_file:
css = css_file.read()
client = FrappeClient(url=ERPNEXT_URL, username=username, password=password)
with os.scandir('print_format') as it:
for entry in it:
html = None
if entry.name not in PRINT_FORMATS:
continue
with open(entry.path) as html_file:
html = html_file.read()
client.update({
'doctype': 'Print Format',
'name': PRINT_FORMATS.get(entry.name),
'html': html,
'css': css
})
if __name__ == '__main__':
main()