Skip to content

Commit

Permalink
fix: patch update print_designer_print_format
Browse files Browse the repository at this point in the history
- update print_designer_print_format to use the new object syntax
  • Loading branch information
maharshivpatel committed Jun 11, 2024
1 parent daff1dc commit 2363ad9
Showing 1 changed file with 26 additions and 6 deletions.
32 changes: 26 additions & 6 deletions print_designer/patches/move_header_footers_to_new_schema.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import frappe

from print_designer.pdf import is_older_schema


def patch_format():
print_formats = frappe.get_all(
Expand Down Expand Up @@ -57,16 +59,34 @@ def patch_format():
"isDropZone": True,
}
]
object_to_save = {
"print_designer_header": frappe.json.dumps(header_data),
"print_designer_body": frappe.json.dumps(bodyPage),
"print_designer_footer": frappe.json.dumps(footer_data),
"print_designer_settings": frappe.json.dumps(settings),
}
if not is_older_schema(settings=settings, current_version="1.1.0"):
pf_print_format = frappe.json.loads(pf.print_designer_print_format)
if "header" in pf_print_format:
pf_print_format["header"] = {
"firstPage": pf_print_format["header"],
"oddPage": pf_print_format["header"],
"evenPage": pf_print_format["header"],
"lastPage": pf_print_format["header"],
}
if "footer" in pf_print_format:
pf_print_format["footer"] = {
"firstPage": pf_print_format["footer"],
"oddPage": pf_print_format["footer"],
"evenPage": pf_print_format["footer"],
"lastPage": pf_print_format["footer"],
}
object_to_save["print_designer_print_format"] = frappe.json.dumps(pf_print_format)

frappe.set_value(
"Print Format",
pf.name,
{
"print_designer_header": frappe.json.dumps(header_data),
"print_designer_body": frappe.json.dumps(bodyPage),
"print_designer_footer": frappe.json.dumps(footer_data),
"print_designer_settings": frappe.json.dumps(settings),
},
object_to_save,
)
return print_formats

Expand Down

0 comments on commit 2363ad9

Please sign in to comment.