frappe: v15: new print format builder - Print button gives Internal Server Error 500 AttributeError: 'str' object has no attribute 'get'
Description of the issue
Try to print a custom new print format from a document
** Custom as-in not a built-in standard, and not a HTML format. Built using the builder
Steps:
- Build the print format
- Navigate to a document
- Click the printer icon
- Click
Print
Context information (for bug reports)
Output of bench version
ERPNext: v15.6.1 (version-15)
Frappe Framework: v15.5.0 (version-15)
Stacktrace / full error message
Traceback (most recent call last):
File "apps/frappe/frappe/website/serve.py", line 18, in get_response
response = renderer_instance.render()
File "apps/frappe/frappe/website/page_renderers/template_page.py", line 84, in render
html = self.get_html()
File "apps/frappe/frappe/website/utils.py", line 524, in cache_html_decorator
html = func(*args, **kwargs)
File "apps/frappe/frappe/website/page_renderers/template_page.py", line 95, in get_html
self.update_context()
File "apps/frappe/frappe/website/page_renderers/template_page.py", line 163, in update_context
data = self.run_pymodule_method("get_context")
File "apps/frappe/frappe/website/page_renderers/template_page.py", line 225, in run_pymodule_method
return method(self.context)
File "apps/frappe/frappe/www/printview.py", line 57, in get_context
body = get_rendered_template(
File "apps/frappe/frappe/www/printview.py", line 158, in get_rendered_template
format_data_map[df.get("fieldname")] = df
AttributeError: 'str' object has no attribute 'get'
About this issue
- Original URL
- State: open
- Created 3 years ago
- Reactions: 2
- Comments: 25 (1 by maintainers)
Hello. I think in version 15, print_format.format_data is in the form of a dictionary, there is no need to convert it. I removed the format_data = json.loads(print_format.format_data) line and got the answer.
I have fixed it. I changed the values in my print.js
Can confirm this issue exists with print formats created with the New print format builder (beta). The preview in the builder shows correctly, and the pdf can be downloaded from the print format page, but trying to “print” from a document page, or sending an email with the print document attached will result in the following error:
Stack trace:
I believe the error happens on this line in printview.py: https://github.com/frappe/frappe/blob/92c4d291c922d64960b642494cac23555a14a6af/frappe/www/printview.py#L173
In issue #19703 , it is mentioned that the new print format is going to be deprecated in v15 - however, it is very useful in creating print formats which are extremely difficult to create using the old print format builder (eg: It’s tough to get the letterhead header and footer to appear on all pages consistently using the custom old print format without a lot of custom code), not to mention that it is much cleaner as well.
A fix would be much appreciated @netchampfaris @ankush
I’m running frappe and erpnext nightly on FrappeCloud
I’ve had feedback that a lot of functionality in ERPNext and frappe is generally being abandoned because a lot of the team are working on their new separate apps (HRMS, Payments, Webshop, CRM, Builder, Helpdesk, …). The print format builder is no exception:
https://github.com/frappe/print_designer
Personally I feel this is a step in the wrong direction, because separate apps will not integrate as well, are more difficult to install, maintain, find errors. And the new apps are being created from scratch without necessarily learning from the lessons of frappe/ERPNext. The tagline of frappe was “batteries included”… looks like they’re removing the batteries.
This one is working https://bhachu.co/printpreview?doctype=NIS+Weighing+Form&name=a053263e0f&print_format=NIS%20Weight%20Form%20Print&no_letterhead=0&letterhead=Farmica%20LH&settings=%7B%7D. This one is not working https://bhachu.co/printview?doctype=NIS%20Weighing%20Form&name=a053263e0f&trigger_print=1&format=NIS%20Weight%20Form%20Print&no_letterhead=0&letterhead=Farmica%20LH&settings=%7B%7D&_lang=en-US. The key difference is those two parameter names.