New: Update product type with update method

This commit is contained in:
Cédric 2019-10-14 22:42:38 +02:00 committed by GitHub
parent 2257706a30
commit 3429cb7c1d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -787,13 +787,14 @@ class Product extends CommonObject
* Update a record into database.
* If batch flag is set to on, we create records into llx_product_batch
*
* @param int $id Id of product
* @param User $user Object user making update
* @param int $notrigger Disable triggers
* @param string $action Current action for hookmanager ('add' or 'update')
* @param int $id Id of product
* @param User $user Object user making update
* @param int $notrigger Disable triggers
* @param string $action Current action for hookmanager ('add' or 'update')
* @param int $updatetype Update product type
* @return int 1 if OK, -1 if ref already exists, -2 if other error
*/
public function update($id, $user, $notrigger = false, $action = 'update')
public function update($id, $user, $notrigger = false, $action = 'update', $updatetype = false)
{
global $langs, $conf, $hookmanager;
@ -939,6 +940,11 @@ class Product extends CommonObject
$sql = "UPDATE ".MAIN_DB_PREFIX."product";
$sql.= " SET label = '" . $this->db->escape($this->label) ."'";
if ($updatetype && ($this->isProduct() || $this->isService())) {
$sql.= ", fk_product_type = " . $this->type;
}
$sql.= ", ref = '" . $this->db->escape($this->ref) ."'";
$sql.= ", ref_ext = ".(! empty($this->ref_ext)?"'".$this->db->escape($this->ref_ext)."'":"null");
$sql.= ", default_vat_code = ".($this->default_vat_code ? "'".$this->db->escape($this->default_vat_code)."'" : "null");