Script zum Anlegen von Feldern hinzugefügt
@@ -0,0 +1,44 @@
|
|||||||
|
`import frappe
|
||||||
|
|
||||||
|
fields = [
|
||||||
|
{"label": "Berchmans Status", "fieldname": "custom_berchmans_status", "fieldtype": "Select", "options": "publish\ndraft\nprivate", "default": "publish"},
|
||||||
|
{"label": "ISBN", "fieldname": "isbn", "fieldtype": "Data"},
|
||||||
|
{"label": "Autor", "fieldname": "autor", "fieldtype": "Data"},
|
||||||
|
{"label": "Untertitel", "fieldname": "untertitel", "fieldtype": "Data"},
|
||||||
|
{"label": "Verlag", "fieldname": "verlag", "fieldtype": "Data"},
|
||||||
|
{"label": "Erscheinungsjahr", "fieldname": "erscheinungsjahr", "fieldtype": "Data"},
|
||||||
|
{"label": "Edition", "fieldname": "edition", "fieldtype": "Data"},
|
||||||
|
{"label": "Produkttyp", "fieldname": "produkttyp", "fieldtype": "Select", "options": "Buch\nComic\nKarte\nFoto\nSchallplatte\nCD\nDVD"},
|
||||||
|
{"label": "Bindung", "fieldname": "bindung", "fieldtype": "Select", "options": "Hardcover\nPaperback\nTaschenbuch\nBroschiert"},
|
||||||
|
{"label": "Zustand", "fieldname": "zustand", "fieldtype": "Select", "options": "Wie neu\nTadellos\nSehr gut\nGut\nBefriedigend\nAusreichend\nSchlecht"},
|
||||||
|
{"label": "Zustand des Schutzumschlages", "fieldname": "zustand_schutzumschlag", "fieldtype": "Select", "options": "Wie neu\nTadellos\nSehr gut\nGut\nBefriedigend\nAusreichend\nSchlecht"},
|
||||||
|
{"label": "Zustandsbeschreibung", "fieldname": "zustandsbeschreibung", "fieldtype": "Small Text"},
|
||||||
|
{"label": "Zusaetzliches", "fieldname": "zusaetzliches", "fieldtype": "Small Text"},
|
||||||
|
{"label": "Kuenstler", "fieldname": "kuenstler", "fieldtype": "Data"},
|
||||||
|
{"label": "Format", "fieldname": "format", "fieldtype": "Data"},
|
||||||
|
{"label": "Umdrehung", "fieldname": "umdrehung", "fieldtype": "Data"},
|
||||||
|
{"label": "Zustand Huelle", "fieldname": "zustand_huelle", "fieldtype": "Select", "options": "Mint\nNear Mint\nFine\nVery Good\nGood\nFair\nPoor"},
|
||||||
|
{"label": "Zustand Platte", "fieldname": "zustand_platte", "fieldtype": "Select", "options": "Mint\nNear Mint\nFine\nVery Good\nGood\nFair\nPoor"},
|
||||||
|
]
|
||||||
|
|
||||||
|
for field in fields:
|
||||||
|
try:
|
||||||
|
if not frappe.db.exists("Custom Field", {"fieldname": field["fieldname"], "dt": "Item"}):
|
||||||
|
doc = frappe.get_doc({
|
||||||
|
"doctype": "Custom Field",
|
||||||
|
"dt": "Item",
|
||||||
|
"fieldname": field["fieldname"],
|
||||||
|
"label": field["label"],
|
||||||
|
"fieldtype": field["fieldtype"],
|
||||||
|
"options": field.get("options"),
|
||||||
|
"default": field.get("default")
|
||||||
|
})
|
||||||
|
doc.insert()
|
||||||
|
print("Feld angelegt: " + field["label"])
|
||||||
|
else:
|
||||||
|
print("Feld existiert bereits: " + field["label"])
|
||||||
|
except Exception as e:
|
||||||
|
print("Fehler bei " + field["label"] + ": " + str(e))
|
||||||
|
|
||||||
|
frappe.db.commit()
|
||||||
|
print("\n=== Alle Felder verarbeitet ===")`
|
||||||
Reference in New Issue
Block a user