forked from Wavyzz/dolibarr
Fix: reorder line after update line with fk_parent_line
This commit is contained in:
@@ -2222,6 +2222,13 @@ class Commande extends CommonObject
|
||||
$staticline=new OrderLine($this->db);
|
||||
$staticline->fetch($rowid);
|
||||
$this->line->oldline = $staticline;
|
||||
|
||||
// Reorder if fk_parent_line change
|
||||
if (! empty($fk_parent_line) && ! empty($staticline->fk_parent_line) && $fk_parent_line != $staticline->fk_parent_line)
|
||||
{
|
||||
$rangmax = $this->line_max($fk_parent_line);
|
||||
$this->line->rang = $rangmax + 1;
|
||||
}
|
||||
|
||||
$this->line->rowid=$rowid;
|
||||
$this->line->desc=$desc;
|
||||
@@ -2250,6 +2257,9 @@ class Commande extends CommonObject
|
||||
$result=$this->line->update();
|
||||
if ($result > 0)
|
||||
{
|
||||
// Reorder if child line
|
||||
if (! empty($fk_parent_line)) $this->line_order(true,'DESC');
|
||||
|
||||
// Mise a jour info denormalisees
|
||||
$this->update_price(1);
|
||||
|
||||
@@ -3095,11 +3105,10 @@ class OrderLine
|
||||
if ($this->date_end) { $sql.= " , date_end='".$this->db->idate($this->date_end)."'"; }
|
||||
$sql.= " , product_type=".$this->product_type;
|
||||
$sql.= " , fk_parent_line=".($this->fk_parent_line>0?$this->fk_parent_line:"null");
|
||||
|
||||
if (! empty($this->rang)) $sql.= ", rang=".$this->rang;
|
||||
$sql.= " WHERE rowid = ".$this->rowid;
|
||||
|
||||
dol_syslog("OrderLine::update sql=$sql");
|
||||
|
||||
dol_syslog(get_class($this)."::update sql=".$sql, LOG_DEBUG);
|
||||
$resql=$this->db->query($sql);
|
||||
if ($resql)
|
||||
{
|
||||
@@ -3119,7 +3128,7 @@ class OrderLine
|
||||
else
|
||||
{
|
||||
$this->error=$this->db->error();
|
||||
dol_syslog("OrderLine::update Error ".$this->error, LOG_ERR);
|
||||
dol_syslog(get_class($this)."::update Error ".$this->error, LOG_ERR);
|
||||
$this->db->rollback();
|
||||
return -2;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user