From 1d4ce231dbcbb6e775b0bc9fe490d5ae6e3cd417 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 27 Jul 2013 12:22:00 +0200 Subject: [PATCH] Add manually patch https://github.com/altatof/dolibarr/commit/9ae9b2b02ad597c4455263226071384c28ac2b0b --- htdocs/product/class/product.class.php | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/htdocs/product/class/product.class.php b/htdocs/product/class/product.class.php index 2c086b42608..7ff3d662ab3 100644 --- a/htdocs/product/class/product.class.php +++ b/htdocs/product/class/product.class.php @@ -262,8 +262,27 @@ class Product extends CommonObject } if (empty($this->ref)) { - $this->error='ErrorWrongParameters'; - return -2; + // Load object modCodeProduct + $module=(! empty($conf->global->PRODUCT_CODEPRODUCT_ADDON)?$conf->global->PRODUCT_CODEPRODUCT_ADDON:'mod_codeproduct_leopard'); + if ($module != 'mod_codeproduct_leopard') // Do not load module file + { + if (substr($module, 0, 16) == 'mod_codeproduct_' && substr($module, -3) == 'php') + { + $module = substr($module, 0, dol_strlen($module)-4); + } + dol_include_once('/core/modules/product/'.$module.'.php'); + $modCodeProduct = new $module; + if (! empty($modCodeProduct->code_auto)) + { + $this->ref = $modCodeProduct->getNextValue($this,$this->type); + } + unset($modCodeProduct); + } + if (empty($this->ref)) + { + $this->error='ProductModuleNotSetupForAutoRef'; + return -2; + } } dol_syslog(get_class($this)."::create ref=".$this->ref." price=".$this->price." price_ttc=".$this->price_ttc." tva_tx=".$this->tva_tx." price_base_type=".$this->price_base_type, LOG_DEBUG);