GithubHelp home page GithubHelp logo

alyf-de / erpnext_pdf-on-submit Goto Github PK

View Code? Open in Web Editor NEW
66.0 5.0 72.0 1.15 MB

Creates a PDF when a document is submitted.

Home Page: https://alyf.de

License: GNU General Public License v3.0

Python 92.98% JavaScript 7.02%
pdf erpnext

erpnext_pdf-on-submit's Introduction

PDF on Submit

Automatically generates and attaches a PDF when a sales document gets submitted. Works for Quotation, Sales Order, Sales Invoice, Delivery Note and Dunning.

Screencast of PDF generation

Install on Frappe Cloud

  1. Go to https://frappecloud.com/dashboard/#/sites and click the "New Site" button.
  2. In Step 2 ("Select apps to install"), select "PDF on Submit".
  3. Complete the new site wizard.

Install on Self-Hosted

cd frappe-bench
bench get-app https://github.com/alyf-de/pdf_on_submit.git
bench --site MY_SITE install-app pdf_on_submit

Remeber to replace MY_SITE with your site name.

Settings

To change the settings of this app, you can open PDF on Submit Settings via the search bar.

  • Choose active DocTypes

    Here you can select for which DocTypes this app is active. DocTypes that are disabled will be ignored.

  • Create PDF in Background

    Enable this option if you want to continue your work immediately. The PDFs will just appear once they are created. (This might require a reload of the current document.) Recommended if you usually submit many sales documents in bulk.

    Disable this option to get the PDF immediately. When you submit the document you will see a progress bar while the PDF gets created. When it's done you immediately see the PDF attached to the document.

PDF on Submit Settings

This app uses the Default Print Format. To change the Default Print Format,

  1. Open the list view of a supported DocType,
  2. Go to Menu > Customize,
  3. In section "View Settings", select a Default Print Format.

The PDF will be created in the language that is specified in the "Language" field of the current document. In your Customer and Supplier masters you can choose the default "Print Language".

Licence

Copyright (C) 2020 ALYF GmbH [email protected]

This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see https://www.gnu.org/licenses/.

erpnext_pdf-on-submit's People

Contributors

barredterra avatar lgtm-com[bot] avatar majubewi avatar mergify[bot] avatar sourcery-ai[bot] avatar vishdha avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

erpnext_pdf-on-submit's Issues

Feature request:

Hi there,

is there any possibility to add also Timesheet to the support DocTypes? That be awesome!

Thanks a lot!

PDF is not created in the customers language

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)

How have you hooked into the On-Submit?

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?

Upload PDF to Amazon S3

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.

Error when creating Stock Entry

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:
image

Any ideas? Thank you!

Send PDF by email

  • Every time a PDF gets created, it should be sent to the customer by email.
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
  • Allow to set an Email Template for every DocType in PDF On Submit Settings.
  • Allow to enable/disable this feature.

Support for V14

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.

FR28 causes v13 to fail submits on any doctypes because of missing weasyprint

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:
image

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.

Missing Import in v14

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:

from frappe.core.doctype.file.file import create_new_folder

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)

PrintFormatBeta, enabled_doctype

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.

Error on Submit

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
grafik

ERPNext: v13.49.12 (version-13)
Frappe Framework: v13.53.2 (version-13)

grafik

Draft Status

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?

PDF Does not fetch the Document Header

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.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.