// Stock : add state management on orders + bugs fix
This commit is contained in:
@@ -182,7 +182,12 @@ class SupplierOrderCore extends ObjectModel
|
||||
{
|
||||
$this->calculatePrices();
|
||||
|
||||
return parent::update($null_values);
|
||||
$return = parent::update($null_values);
|
||||
|
||||
if ($return)
|
||||
$this->addHistory();
|
||||
|
||||
return $return;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -192,7 +197,12 @@ class SupplierOrderCore extends ObjectModel
|
||||
{
|
||||
$this->calculatePrices();
|
||||
|
||||
return parent::add($autodate, $null_values);
|
||||
$return = parent::add($autodate, $null_values);
|
||||
|
||||
if ($return)
|
||||
$this->addHistory();
|
||||
|
||||
return $return;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -301,4 +311,19 @@ class SupplierOrderCore extends ObjectModel
|
||||
|
||||
return (Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue($query) == 1);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add order history
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
protected function addHistory()
|
||||
{
|
||||
$history = new SupplierOrderHistory();
|
||||
$history->id_supplier_order = $this->id;
|
||||
$history->id_state = $this->id_supplier_order_state;
|
||||
$history->id_employee = $this->id_employee;
|
||||
|
||||
$history->save();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user