Hello,
I want to use Reference Number as a Barcode value. Is there a any way to auto fill to barcode value? Thank you.
Hello,
I want to use Reference Number as a Barcode value. Is there a any way to auto fill to barcode value? Thank you.
Hi,
if you want to have the ref as a barcode then that is possible via javascript…
You have to edit the source ~htdocs\product\card.php
Search for
print dol_get_fiche_head('');
print '<table class="border centpercent">';
if (empty($conf->global->PRODUCT_GENERATE_REF_AFTER_FORM)) {
and insert the following code after the “{” :
print '<script type="text/javascript">
$(document).on("input", "#ref", function () {
var new_qrcode = $("#ref").val();
$("#barcode").val(new_qrcode);
});
</script>';
As a result, the barcode is automatically filled in when the product reference is entered during new product creation.
Thanks for your help but it is not work.
My code is
print dol_get_fiche_head('');
print '<table class="border centpercent">';
if (empty($conf->global->PRODUCT_GENERATE_REF_AFTER_FORM)) {
print '<script type="text/javascript">
$(document).on("input", "#ref", function () {
var new_qrcode = $("#ref").val();
$("#barcode").val(new_qrcode);
});
</script>';
print '<tr>';
$tmpcode = '';
if (!empty($modCodeProduct->code_auto)) {
$tmpcode = $modCodeProduct->getNextValue($object, $type);
}
We use it in Version 17.0.2 without problems
Please check if you have set the global variable PRODUCT_GENERATE_REF_AFTER_FORM
And you can also debug the javascript with your browser tools to see if the script is triggered.
i am using 22.0.2, i could not find such lines in card.php ![]()
print dol_get_fiche_head(‘’);
print '<table class="border centpercent">';
if (empty($conf->global->PRODUCT_GENERATE_REF_AFTER_FORM)) {
you can find the “PRODUCT_GENERATE_REF_AFTER_FORM” in line 1504
// Call Hook tabContentCreateProduct
$parameters = array();
// Note that $action and $object may be modified by hook
$reshook = $hookmanager->executeHooks('tabContentCreateProduct', $parameters, $object, $action);
if (empty($reshook)) {
print '<table class="border centpercent">';
if (!getDolGlobalString('PRODUCT_GENERATE_REF_AFTER_FORM')) {
and insert the following code after the “{” :
print '<script type="text/javascript">
$(document).on("input", "#ref", function () {
var new_qrcode = $("#ref").val();
$("#barcode").val(new_qrcode);
});
</script>';
Thanks a lot for the guidence.
It is showing while creating a new product, but not in existing product while listing / browsing individual
but not in existing saved products
That’s right, only when creating a new product is the “Barcode value” field filled in with the value entered in the “Ref” field.
I would rather use a ulid as the barcode - possibly generating one when creating a product