-
Notifications
You must be signed in to change notification settings - Fork 129
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
62 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
60 changes: 60 additions & 0 deletions
60
print_designer/patches/convert_formats_for_recursive_container.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
import frappe | ||
|
||
from print_designer.pdf import is_older_schema | ||
|
||
|
||
def patch_format(): | ||
print_formats = frappe.get_all( | ||
"Print Format", | ||
filters={"print_designer": 1}, | ||
fields=[ | ||
"name", | ||
"print_designer_print_format", | ||
"print_designer_settings", | ||
], | ||
) | ||
for pf in print_formats: | ||
settings = frappe.json.loads(pf.print_designer_settings or "{}") | ||
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) | ||
|
||
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]: | ||
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, | ||
} | ||
] | ||
|
||
frappe.set_value( | ||
"Print Format", | ||
pf.name, | ||
{"print_designer_print_format": frappe.json.dumps(pf_print_format)}, | ||
) | ||
|
||
return print_formats | ||
|
||
|
||
def execute(): | ||
"""add layoutType to rows and columns in old print formats.""" | ||
patch_format() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters