alyf-de / erpnext_pdf-on-submit Goto Github PK
View Code? Open in Web Editor NEWCreates a PDF when a document is submitted.
Home Page: https://alyf.de
License: GNU General Public License v3.0
Creates a PDF when a document is submitted.
Home Page: https://alyf.de
License: GNU General Public License v3.0
Caused by #28
After we updated the app, we cannot submit any documents anymore.
I think I ready weasyprint is for v14, but hope that's not misleading here.
I attached the error backtrace here:
Perhaps weasyprint can be added to the requirements if I am wrong with my information to be related to v14?
But for now we needed to deinstall the app quickly; would be great if the dependencies could be checked or made somehow other (backwards) compatible
Let me know if you need more details.
Hi there,
is there any possibility to add also Timesheet to the support DocTypes? That be awesome!
Thanks a lot!
Dear, thank you for your support, i have noticed that when a pdf is created, it is always created on a draft status, is this intentional?
When the document is submitted and pdf is created successfully. when i open the pdf file, it includes only the format of the document without the Letter Head and without the Header that is included in the doument format it self, So the Quotation Titleis not shown on the document.
The document created is always saved in the default language. If the customer's default language is different (e.g. English instead of German), this is not taken into account.
Installed Apps
ERPNext: v14.66.3 (HEAD)
ERPNext DATEV Integration: v14.1.3 (HEAD)
ERPNext Germany: v14.6.1 (HEAD)
ERPNext Shipping: v14.3.4 (HEAD)
Frappe Framework: v14.70.0 (HEAD)
Helpdesk: v0.10.0 (HEAD)
Frappe HR: v14.24.2 (HEAD)
PDF on Submit: v14.0.5 (HEAD)
When submitting a document I get an error at the moment:
ModuleNotFoundError: No module named 'frappe.core.api'
The error is:
Traceback (most recent call last):
File "apps/frappe/frappe/app.py", line 66, in application
response = frappe.api.handle()
File "apps/frappe/frappe/api.py", line 55, in handle
return frappe.handler.handle()
File "apps/frappe/frappe/handler.py", line 38, in handle
data = execute_cmd(cmd)
File "apps/frappe/frappe/handler.py", line 76, in execute_cmd
return frappe.call(method, **frappe.form_dict)
File "apps/frappe/frappe/__init__.py", line 1473, in call
return fn(*args, **newargs)
File "apps/frappe/frappe/desk/form/save.py", line 22, in savedocs
doc.submit()
File "apps/frappe/frappe/model/document.py", line 1020, in submit
return self._submit()
File "apps/frappe/frappe/model/document.py", line 1009, in _submit
return self.save()
File "apps/frappe/frappe/model/document.py", line 312, in save
return self._save(*args, **kwargs)
File "apps/frappe/frappe/model/document.py", line 366, in _save
self.run_post_save_methods()
File "apps/frappe/frappe/model/document.py", line 1090, in run_post_save_methods
self.run_method("on_submit")
File "apps/frappe/frappe/model/document.py", line 943, in run_method
out = Document.hook(fn)(self, *args, **kwargs)
File "apps/frappe/frappe/model/document.py", line 1261, in composer
hooks.append(frappe.get_attr(handler))
File "apps/frappe/frappe/__init__.py", line 1463, in get_attr
return getattr(get_module(modulename), methodname)
File "apps/frappe/frappe/__init__.py", line 1205, in get_module
return importlib.import_module(modulename)
File "env/lib/python3.9/importlib/__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1030, in _gcd_import
File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
File "<frozen importlib._bootstrap>", line 986, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 680, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 850, in exec_module
File "<frozen importlib._bootstrap>", line 228, in _call_with_frames_removed
File "apps/pdf_on_submit/pdf_on_submit/attach_pdf.py", line 22, in <module>
from frappe.core.api.file import create_new_folder
ModuleNotFoundError: No module named 'frappe.core.api'
This was tried on a Quotation with the following settings
ERPNext: v13.49.12 (version-13)
Frappe Framework: v13.53.2 (version-13)
Every time a PDF is attached to a Quotation, Sales Order or Sales Invoice, it should be uploaded to S3. The S3 folder should be protected from deletion.
Reference implementation: S3 Backup Settings.
I'm interested in extending this software to automatically send each submitted document/PDF to Amazon S3 (possible FTP and other transfer methods/protocols as well).
I have a client that needs offsite backups of certain Documents created automatically. So, once the Document is submitted, the PDF would be sent to Amazon S3/FTP.
Using your plugin, is there a way I can hook into the PDF creation and execute some code to send the PDF to where it needs to go?
DEPRECATION: Legacy editable install of pdf-on-submit==15.1.0 from file:///home/ubuntu/frappe-bench/apps/pdf_on_submit (setup.py develop) is deprecated. pip 25.0 will enforce this behaviour change. A possible replacement is to add a pyproject.toml or enable --use-pep517, and use setuptools >= 64. If the resulting installation is not behaving as expected, try using --config-settings editable_mode=compat. Please consult the setuptools documentation for more information. Discussion can be found at pypa/pip#11457
To avoid future naming conflicts
Hi,
since a recent update I get an error when trying to create a Stock Entry:
App Versions
{ "erpnext": "13.42.5", "fieldtime_tracker": "0.0.1", "frappe": "13.46.1", "pdf_on_submit": "13.2", "stock_addon": "0.0.1" }
Route
Form/Stock Entry/MAT-STE-2022-00145
Trackeback
Traceback (most recent call last): File "apps/frappe/frappe/app.py", line 69, in application response = frappe.api.handle() File "apps/frappe/frappe/api.py", line 55, in handle return frappe.handler.handle() File "apps/frappe/frappe/handler.py", line 38, in handle data = execute_cmd(cmd) File "apps/frappe/frappe/handler.py", line 76, in execute_cmd return frappe.call(method, **frappe.form_dict) File "apps/frappe/frappe/__init__.py", line 1457, in call return fn(*args, **newargs) File "apps/frappe/frappe/desk/form/save.py", line 22, in savedocs doc.submit() File "apps/frappe/frappe/model/document.py", line 1019, in submit return self._submit() File "apps/frappe/frappe/model/document.py", line 1008, in _submit return self.save() File "apps/frappe/frappe/model/document.py", line 311, in save return self._save(*args, **kwargs) File "apps/frappe/frappe/model/document.py", line 365, in _save self.run_post_save_methods() File "apps/frappe/frappe/model/document.py", line 1089, in run_post_save_methods self.run_method("on_submit") File "apps/frappe/frappe/model/document.py", line 942, in run_method out = Document.hook(fn)(self, *args, **kwargs) File "apps/frappe/frappe/model/document.py", line 1262, in composer hooks.append(frappe.get_attr(handler)) File "apps/frappe/frappe/__init__.py", line 1447, in get_attr return getattr(get_module(modulename), methodname) File "apps/frappe/frappe/__init__.py", line 1200, in get_module return importlib.import_module(modulename) File "/usr/lib/python3.7/importlib/__init__.py", line 127, in import_module return _bootstrap._gcd_import(name[level:], package, level) File "<frozen importlib._bootstrap>", line 1006, in _gcd_import File "<frozen importlib._bootstrap>", line 983, in _find_and_load File "<frozen importlib._bootstrap>", line 967, in _find_and_load_unlocked File "<frozen importlib._bootstrap>", line 677, in _load_unlocked File "<frozen importlib._bootstrap_external>", line 724, in exec_module File "<frozen importlib._bootstrap_external>", line 860, in get_code File "<frozen importlib._bootstrap_external>", line 791, in source_to_code File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed File "apps/pdf_on_submit/pdf_on_submit/attach_pdf.py", line 31 if enabled_doctypes := settings.get("enabled_for", {"document_type": doc.doctype}): ^ SyntaxError: invalid syntax
Request Data
{ "type": "POST", "args": { "doc": "{\"name\":\"MAT-STE-2022-00145\",\"owner\":\"Administrator\",\"creation\":\"2022-12-20 14:24:31.437776\",\"modified\":\"2022-12-20 17:42:14.923304\",\"modified_by\":\"Administrator\",\"idx\":0,\"docstatus\":0,\"naming_series\":\"MAT-STE-.YYYY.-\",\"stock_entry_type\":\"Annahme\",\"purpose\":\"Material Receipt\",\"add_to_transit\":0,\"company\":\"Company GmbH\",\"posting_date\":\"2022-12-20\",\"posting_time\":\"17:42:14.95409\",\"set_posting_time\":0,\"inspection_required\":0,\"from_bom\":0,\"apply_putaway_rule\":0,\"fg_completed_qty\":0,\"use_multi_level_bom\":1,\"total_outgoing_value\":0,\"total_incoming_value\":0,\"value_difference\":0,\"total_additional_costs\":0,\"project\":\"\",\"zustand\":\"Neu\",\"letter_head\":\"Default Letter Head\",\"is_opening\":\"No\",\"per_transferred\":0,\"total_amount\":0,\"is_return\":0,\"doctype\":\"Stock Entry\",\"items\":[{\"name\":\"a85dd0c5c6\",\"owner\":\"Administrator\",\"creation\":\"2022-12-20 14:24:31.437776\",\"modified\":\"2022-12-20 17:42:14.923304\",\"modified_by\":\"Administrator\",\"parent\":\"MAT-STE-2022-00145\",\"parentfield\":\"items\",\"parenttype\":\"Stock Entry\",\"idx\":1,\"docstatus\":0,\"t_warehouse\":\"B5O_18 - SC\",\"item_code\":\"RESU 10M\",\"item_name\":\"LG Chem RESU 10M\",\"is_finished_item\":0,\"is_scrap_item\":0,\"is_process_loss\":0,\"description\":\"LG Chem *RESU 10M\",\"item_group\":\"Batterie\",\"image\":\"/files/RESU10M_24dVfWYDVmnpkP.jpg\",\"qty\":1,\"transfer_qty\":1,\"retain_sample\":0,\"uom\":\"Stk\",\"stock_uom\":\"Stk\",\"conversion_factor\":1,\"sample_quantity\":0,\"basic_rate\":0,\"additional_cost\":0,\"valuation_rate\":0,\"allow_zero_valuation_rate\":1,\"set_basic_rate_manually\":0,\"basic_amount\":0,\"amount\":0,\"serial_no\":\"R5555555\",\"expense_account\":\"8977 - Bestandsveränderung Aufträge in Arbeit - SC\",\"cost_center\":\"0 - Haupt - SC\",\"project\":\"PS221967\",\"zustand\":\"Neu\",\"actual_qty\":0,\"transferred_qty\":0,\"allow_alternative_item\":0,\"doctype\":\"Stock Entry Detail\"}],\"additional_costs\":[],\"__last_sync_on\":\"2022-12-21T09:48:08.685Z\",\"address_display\":null,\"purchase_receipt_no\":null,\"supplier_address\":null,\"supplier_name\":null,\"supplier\":null,\"sales_invoice_no\":null,\"delivery_note_no\":null,\"customer_address\":null,\"customer_name\":null,\"customer\":null}", "action": "Submit" }, "btn": { "jQuery224038353808349558341": { "events": { "click": [ { "type": "click", "origType": "click", "guid": 566, "namespace": "" } ] } } }, "freeze": true, "headers": {}, "error_handlers": {}, "url": "/api/method/frappe.desk.form.save.savedocs" }
Response Data
{ "exception": "SyntaxError: invalid syntax" }
I have not set the option, that a PDF is created on Stock Entry or any other DocType directly connected to this. My settings are:
Any ideas? Thank you!
Many thanks for adapting pdf_on_submit for PrintFormatBeat.
I think there is an erorr in attach_pdf.py
28 def attach_pdf(doc, event=None):
29 settings = frappe.get_single("PDF on Submit Settings")
30
31 if enabled_doctypes := settings.get("enabled_for", {"document_type": doc.doctype}):
32 enabled_doctype = enabled_doctypes[0]
33 else:
34 return
The enabled doctypes are stored in its own tabEnabled Doctype an not in tabSingles. So enabled_doctypes[] is empty.
On line 90 will always False and doctypes with PrintFormatBeta wont get printed.
If I set line 90 to if (True): and i have doctypes with PrintFormatBeta they will print fine.
contact_email_list = frappe.get_list('Contact Email', fields=['email_id'], filters={'parent': sinv.contact_person, 'is_primary': 1})
contact_email = contact_email_list[0].get('email_id') if contact_email_list else None
address_email = frappe.get_value('Address', sinv.customer_address, 'email_id')
to_mail = contact_email or address_email
Please publish the app on Frappe Cloud market place for Version 14. Currently, only V13 and V12 are supported.
Version 14 has been out since several weeks and we would like to migrate to V14 as soon as our installed apps are supported on V14.
Do you have a rough time plan until when this could be achieved? In case this is not planned right now, we might prefer to drop the integration and migrate to V14 without it if it takes a bit longer.
Thank you.
In v14 there is no function with create_new_folder, everytime the document is first submited there came an error. Sometime it works but like the code it cant work? At the moment all doctypes removed but the error persists.
Frappe:
https://github.com/frappe/frappe/blob/17f94ac9979c30d2e9c4a56489431147dfca6445/frappe/core/doctype/file/file.py#L31
PDF on Submit:
Traceback (most recent call last):
File "apps/frappe/frappe/app.py", line 69, in application
response = frappe.api.handle()
File "apps/frappe/frappe/api.py", line 54, in handle
return frappe.handler.handle()
File "apps/frappe/frappe/handler.py", line 45, in handle
data = execute_cmd(cmd)
File "apps/frappe/frappe/handler.py", line 83, in execute_cmd
return frappe.call(method, **frappe.form_dict)
File "apps/frappe/frappe/init.py", line 1581, in call
return fn(*args, **newargs)
File "apps/frappe/frappe/desk/form/save.py", line 21, in savedocs
doc.submit()
File "apps/frappe/frappe/model/document.py", line 999, in submit
return self._submit()
File "apps/frappe/frappe/model/document.py", line 978, in _submit
return self.save()
File "apps/frappe/frappe/model/document.py", line 303, in save
return self._save(*args, **kwargs)
File "apps/frappe/frappe/model/document.py", line 354, in _save
self.run_post_save_methods()
File "apps/frappe/frappe/model/document.py", line 1079, in run_post_save_methods
self.run_method("on_submit")
File "apps/frappe/frappe/model/document.py", line 908, in run_method
out = Document.hook(fn)(self, *args, **kwargs)
File "apps/frappe/frappe/model/document.py", line 1257, in composer
hooks.append(frappe.get_attr(handler))
File "apps/frappe/frappe/init.py", line 1571, in get_attr
return getattr(get_module(modulename), methodname)
File "apps/frappe/frappe/init.py", line 1319, in get_module
return importlib.import_module(modulename)
File "/usr/lib/python3.10/importlib/init.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "", line 1050, in _gcd_import
File "", line 1027, in _find_and_load
File "", line 1006, in _find_and_load_unlocked
File "", line 688, in _load_unlocked
File "", line 883, in exec_module
File "", line 241, in _call_with_frames_removed
File "apps/pdf_on_submit/pdf_on_submit/attach_pdf.py", line 22, in
from frappe.core.doctype.file.file import create_new_folder
ImportError: cannot import name 'create_new_folder' from 'frappe.core.doctype.file.file' (apps/frappe/frappe/core/doctype/file/file.py)
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.