Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: patch utils for old patches #260

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions print_designer/patches.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
[pre_model_sync]
print_designer.patches.introduce_dynamic_containers
execute:from print_designer.patches.create_custom_fields import custom_field_patch; custom_field_patch() #208

[post_model_sync]
print_designer.patches.update_white_space_property
print_designer.patches.introduce_barcode
print_designer.patches.introduce_jinja
Expand All @@ -6,9 +11,7 @@ print_designer.patches.rerun_introduce_jinja
print_designer.patches.introduce_table_alt_row_styles
print_designer.patches.introduce_column_style
print_designer.patches.introduce_suffix_dynamic_content
print_designer.patches.introduce_dynamic_containers
print_designer.patches.introduce_dynamic_height
print_designer.patches.remove_unused_rectangle_gs_properties
execute:from print_designer.patches.create_custom_fields import custom_field_patch; custom_field_patch()
print_designer.patches.change_dynamic_height_variable
print_designer.patches.introduce_z_index
7 changes: 4 additions & 3 deletions print_designer/patches/patch_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ def patch_formats(
for pf in print_formats:
print_json = pf[5] or "{}"
# print_designer_print_format was introduced in schema version 1.1.0 so running this on older version is not required
pf_doc = frappe.get_doc("Print Format", pf[0])
if update_print_json and not is_older_schema(
settings=frappe.json.loads(pf[6] or "{}"), current_version="1.1.0"
):
Expand All @@ -120,8 +121,9 @@ def patch_formats(
if print_json.get("footer", None):
print_json["footer"] = patch_elements(print_json["footer"], callbacks, types)
print_json = frappe.json.dumps(print_json)
pf_doc.update({"print_designer_print_format": print_json})

updated_doc = frappe.get_doc("Print Format", pf[0]).update(
pf_doc.update(
{
"print_designer_header": frappe.json.dumps(
patch_elements(frappe.json.loads(pf[1] or "[]"), callbacks, types)
Expand All @@ -135,11 +137,10 @@ def patch_formats(
"print_designer_footer": frappe.json.dumps(
patch_elements(frappe.json.loads(pf[4] or "[]"), callbacks, types)
),
"print_designer_print_format": print_json,
}
)
if save:
updated_doc.save(ignore_permissions=True, ignore_version=False)
pf_doc.save(ignore_permissions=True, ignore_version=False)


def patch_elements(
Expand Down
Loading