From 324930d438af6db39e5298b308da9fc59ab8995a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alo=C3=AFs=20Micard?= Date: Sat, 14 Mar 2026 18:59:52 +0100 Subject: [PATCH] Fix automatic barcode generation in product update (#37487) * Fix automatic barcode generation in product update * Fix comment --- htdocs/product/class/product.class.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/htdocs/product/class/product.class.php b/htdocs/product/class/product.class.php index 478b7181ab1..6de28569dc7 100644 --- a/htdocs/product/class/product.class.php +++ b/htdocs/product/class/product.class.php @@ -1481,6 +1481,11 @@ class Product extends CommonObject $this->stockable_product = 0; } + // For automatic creation during update action (not used by Dolibarr GUI, can be used by scripts) + if ($this->barcode == '-1' || $this->barcode == 'auto') { + $this->barcode = $this->get_barcode($this, $this->barcode_type_code); + } + // Barcode value $this->barcode = (empty($this->barcode) ? '' : trim($this->barcode)); @@ -1565,11 +1570,6 @@ class Product extends CommonObject } } - // For automatic creation - if ($this->barcode == -1) { - $this->barcode = $this->get_barcode($this, $this->barcode_type_code); - } - $sql = "UPDATE ".$this->db->prefix()."product"; $sql .= " SET label = '".$this->db->escape($this->label)."'";