Hi
On a V15 server , I had the following client script code to create a BLUE button ..
if (!frm.doc.__islocal && frm.doc.docstatus === 0) { // if doc saved but not submitted
frm.add_custom_button('Get Barcode', function() { // add button
frm.set_value('custom_po_barcode', frm.doc.name); // set barcode field
frm.refresh_field('custom_po_barcode');
}).css("background-color", "#00bfff").css("color", "#ffffff");
}
When using this code, the barcode field does not render as a barcode in print-preview mode, but as text.
Although on the deskview of the open PO doc, the barcode is in fact visible.
So this is a print-preview error.
When I change the code to auto-populate, like this …..
rappe.ui.form.on('Purchase Order', {
refresh(frm) {
// your code here
if (!frm.doc.__islocal && frm.doc.docstatus === 0) {
if (!frm.doc.custom_po_barcode) {
frm.set_value('custom_po_barcode', frm.doc.name);
frm.refresh_field('custom_po_barcode');
}
}
}
});
Then the barcode renders properly in print-preview.
The deduction I have to make, is that the CSS directive in the add_custom_button code, interfered with the
rendering of the barcode in print-preview.
If I want to redo the add_custom_button code, then another way to do this would be…..
In a custom CSS file…..
.btn-get-barcode {
background-color: #1e88e5;
color: white;
}
And then the client script should change like this ….
frm.add_custom_button(__('Get Barcode'), () => {
// logic
}).addClass('btn-get-barcode');
My question…
If I create a custom CSS file, how and where to I load it onto my server ?