Skip to content

Commit

Permalink
chore: fix patch again :( (#290)
Browse files Browse the repository at this point in the history
  • Loading branch information
maharshivpatel authored Jun 18, 2024
2 parents bcf976f + a524d36 commit fdee4b9
Showing 1 changed file with 41 additions and 22 deletions.
63 changes: 41 additions & 22 deletions print_designer/patches/convert_formats_for_recursive_container.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,33 +18,52 @@ def patch_format():
if not is_older_schema(settings=settings, current_version="1.1.0") and is_older_schema(
settings=settings, current_version="1.3.0"
):
pf_print_format = frappe.json.loads(pf.print_designer_print_format)
pf_print_format = frappe.json.loads(pf.print_designer_print_format or "{}")

for headerType in ["firstPage", "oddPage", "evenPage", "lastPage"]:
for row in pf_print_format["header"][headerType]:
row["layoutType"] = "row"
for column in row["childrens"]:
column["layoutType"] = "column"
if pf_print_format.get("header", False):
if type(pf_print_format["header"]) == list:
# issue #285
pf_print_format["header"] = {
"firstPage": pf_print_format["header"],
"oddPage": pf_print_format["header"],
"evenPage": pf_print_format["header"],
"lastPage": pf_print_format["header"],
}
for headerType in ["firstPage", "oddPage", "evenPage", "lastPage"]:
for row in pf_print_format["header"][headerType]:
row["layoutType"] = "row"
for column in row["childrens"]:
column["layoutType"] = "column"

for footerType in ["firstPage", "oddPage", "evenPage", "lastPage"]:
for row in pf_print_format["footer"][footerType]:
if pf_print_format.get("footer", False):
if type(pf_print_format["footer"]) == list:
# issue #285
pf_print_format["footer"] = {
"firstPage": pf_print_format["footer"],
"oddPage": pf_print_format["footer"],
"evenPage": pf_print_format["footer"],
"lastPage": pf_print_format["footer"],
}
for footerType in ["firstPage", "oddPage", "evenPage", "lastPage"]:
for row in pf_print_format["footer"][footerType]:
row["layoutType"] = "row"
for column in row["childrens"]:
column["layoutType"] = "column"

if pf_print_format.get("body", False):
for row in pf_print_format["body"]:
row["layoutType"] = "row"
for column in row["childrens"]:
column["layoutType"] = "column"

for row in pf_print_format["body"]:
row["layoutType"] = "row"
for column in row["childrens"]:
column["layoutType"] = "column"
# body elements should be inside page object forgot to add it in patch move_header_footers_to_new_schema
pf_print_format["body"] = [
{
"index": 0,
"type": "page",
"childrens": pf_print_format["body"],
"isDropZone": True,
}
]
# body elements should be inside page object forgot to add it in patch move_header_footers_to_new_schema
pf_print_format["body"] = [
{
"index": 0,
"type": "page",
"childrens": pf_print_format["body"],
"isDropZone": True,
}
]

frappe.set_value(
"Print Format",
Expand Down

0 comments on commit fdee4b9

Please sign in to comment.