We are receiving an error when we generate an invoice and Save it – probably due to the custom script. Can anyone see an issue since the last upgrade as that’s when the issue started? If it helps the Standard Reply code appears in the popup form on Submit but the actual text of the reply doesn’t. If you remove “Invoice” from the standard reply field and re-add it, the text then appears in the body of the email.
The error text is last below, but first this is the custom script within Sales Invoice. One section of it is designed to auto-insert the Standard Reply of “Invoice”:
frappe.ui.form.on("Sales Invoice", "refresh", function(frm){
var old_name = frm.docname, sales_order = frm.doc.items[0].sales_order.replace("M", "M-");
if (!frm.doc.__islocal && sales_order && frm.doc.name!==sales_order){
frappe.call({
method: 'frappe.model.rename_doc.rename_doc',
args: {
doctype: frm.doctype,
old: frm.docname,
"new": sales_order,
"merge": false
},
callback: function(res){
if (!res.exc){
frappe.model.remove_from_locals(frm.doctype, old_name);
frappe.set_route("Form", frm.doctype, sales_order);
}
}
});
}
});
// Below fetches the deposit and po_no fields from the Order onto Invoice
cur_frm.add_fetch('sales_order', 'deposit', 'deposit');
cur_frm.add_fetch('sales_order', 'po_no', 'po_no');
// Below sets the Email Standard Reply field to "Invoice"
cur_frm.email_doc = function(message) {
var composer = new frappe.views.CommunicationComposer({
doc: cur_frm.doc,
frm: cur_frm,
attach_document_print: true,
message: message,
real_name: this.doc.real_name || this.doc.contact_display || this.doc.contact_name
});
composer.dialog.get_input('standard_reply').val('Invoice').trigger('change');
composer.dialog.set_value('send_me_a_copy', false);
}
// Added by max.morais.dmm@gmail.com
cur_frm.cscript._on_submit = cur_frm.cscript.on_submit;
cur_frm.email_doc = function(message){
debugger;
frappe.call({
'method': 'frappe.client.get_value',
'args': {
'doctype': 'Address',
'filters': {
'customer': cur_frm.doc.customer,
'is_primary_address': 1
},
'fieldname': 'email_id'
},
callback: function(res){
var composer = new frappe.views.CommunicationComposer({
doc: cur_frm.doc,
frm: cur_frm,
subject: __(cur_frm.doctype) + ': ' + cur_frm.docname,
recipients: (res.message && res.message.email_id) || cur_frm.doc.email || cur_frm.doc.email_id || cur_frm.doc.contact_email,
attach_document_print: true,
message: message,
real_name: cur_frm.doc.real_name || cur_frm.doc.contact_display || cur_frm.doc.contact_name
});
composer.dialog.get_input('standard_reply').val('Invoice').trigger('change');
composer.dialog.set_value('send_me_a_copy', false);
}
})
}
cur_frm.cscript.on_submit = function(doc, cdt, cdn){
cur_frm.cscript._on_submit(doc, cdt, cdn);
}
Something went wrong
Close
Server Error: Please check your server logs or contact tech support.
Traceback (most recent call last):
File “/home/frappe/benches/bench-2017-07-07-a/apps/frappe/frappe/app.py”, line 56, in application
response = frappe.handler.handle()
File “/home/frappe/benches/bench-2017-07-07-a/apps/frappe/frappe/handler.py”, line 21, in handle
data = execute_cmd(cmd)
File “/home/frappe/benches/bench-2017-07-07-a/apps/frappe/frappe/handler.py”, line 52, in execute_cmd
return frappe.call(method, **frappe.form_dict)
File “/home/frappe/benches/bench-2017-07-07-a/apps/frappe/frappe/init.py”, line 913, in call
return fn(*args, **newargs)
File “/home/frappe/benches/bench-2017-07-07-a/apps/frappe/frappe/model/rename_doc.py”, line 39, in rename_doc
new = validate_rename(doctype, new, meta, merge, force, ignore_permissions)
File “/home/frappe/benches/bench-2017-07-07-a/apps/frappe/frappe/model/rename_doc.py”, line 113, in validate_rename
exists = frappe.db.sql(“select name from tab{doctype}
where name=%s for update”.format(doctype=frappe.db.escape(doctype)), new)
File “/home/frappe/benches/bench-2017-07-07-a/apps/frappe/frappe/database.py”, line 142, in sql
self._cursor.execute(query, values)
File “/home/frappe/benches/bench-2017-07-07-a/env/lib/python2.7/site-packages/MySQLdb/cursors.py”, line 250, in execute
self.errorhandler(self, exc, value)
File “/home/frappe/benches/bench-2017-07-07-a/env/lib/python2.7/site-packages/MySQLdb/connections.py”, line 50, in defaulterrorhandler
raise errorvalue
OperationalError: (1213, ‘Deadlock found when trying to get lock; try restarting transaction’