fix: button click event not working in POS custom fields (#23358)
This commit is contained in:
parent
bbc6aee803
commit
c29ee691d4
@ -7,10 +7,10 @@ frappe.ui.form.on('POS Settings', {
|
||||
},
|
||||
|
||||
get_invoice_fields: function(frm) {
|
||||
frappe.model.with_doctype("Sales Invoice", () => {
|
||||
var fields = $.map(frappe.get_doc("DocType", "Sales Invoice").fields, function(d) {
|
||||
frappe.model.with_doctype("POS Invoice", () => {
|
||||
var fields = $.map(frappe.get_doc("DocType", "POS Invoice").fields, function(d) {
|
||||
if (frappe.model.no_value_type.indexOf(d.fieldtype) === -1 ||
|
||||
d.fieldtype === 'Table') {
|
||||
['Table', 'Button'].includes(d.fieldtype)) {
|
||||
return { label: d.label + ' (' + d.fieldtype + ')', value: d.fieldname };
|
||||
} else {
|
||||
return null;
|
||||
@ -25,7 +25,7 @@ frappe.ui.form.on('POS Settings', {
|
||||
frappe.ui.form.on("POS Field", {
|
||||
fieldname: function(frm, doctype, name) {
|
||||
var doc = frappe.get_doc(doctype, name);
|
||||
var df = $.map(frappe.get_doc("DocType", "Sales Invoice").fields, function(d) {
|
||||
var df = $.map(frappe.get_doc("DocType", "POS Invoice").fields, function(d) {
|
||||
return doc.fieldname == d.fieldname ? d : null;
|
||||
})[0];
|
||||
|
||||
|
@ -70,13 +70,23 @@ erpnext.PointOfSale.Payment = class {
|
||||
this.$invoice_fields.append(
|
||||
`<div class="invoice_detail_field ${df.fieldname}-field" data-fieldname="${df.fieldname}"></div>`
|
||||
);
|
||||
let df_events = {
|
||||
onchange: function() { frm.set_value(this.df.fieldname, this.value); }
|
||||
}
|
||||
if (df.fieldtype == "Button") {
|
||||
df_events = {
|
||||
click: function() {
|
||||
if (frm.script_manager.has_handlers(df.fieldname, frm.doc.doctype)) {
|
||||
frm.script_manager.trigger(df.fieldname, frm.doc.doctype, frm.doc.docname);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
this[`${df.fieldname}_field`] = frappe.ui.form.make_control({
|
||||
df: {
|
||||
...df,
|
||||
onchange: function() {
|
||||
frm.set_value(this.df.fieldname, this.value);
|
||||
}
|
||||
...df_events
|
||||
},
|
||||
parent: this.$invoice_fields.find(`.${df.fieldname}-field`),
|
||||
render_input: true,
|
||||
|
Loading…
x
Reference in New Issue
Block a user