/**
  * @see parent::store()
  */
 function store()
 {
     $this->completeField("order_id", "reference_id", "renewal", "septic");
     if (!$this->_id) {
         if ($this->renewal === null) {
             $this->renewal = "1";
         }
         if ($this->septic === null) {
             $this->septic = "0";
         }
     }
     if ($this->order_id && $this->reference_id && !$this->_id) {
         $this->loadRefsFwd();
         $where = array('order_id' => "= '{$this->order_id}'", 'reference_id' => "= '{$this->reference_id}'", 'renewal' => "= '{$this->renewal}'", 'septic' => "= '{$this->septic}'");
         if ($this->lot_id) {
             $where['lot_id'] = "= '{$this->lot_id}'";
         }
         $duplicateKey = new CProductOrderItem();
         if ($duplicateKey->loadObject($where)) {
             $duplicateKey->loadRefsFwd();
             $this->_id = $duplicateKey->_id;
             $this->quantity += $duplicateKey->quantity;
             $this->unit_price = $duplicateKey->unit_price;
             $this->tva = $duplicateKey->tva;
         } else {
             $this->unit_price = $this->_ref_reference->price;
             $this->tva = $this->_ref_reference->tva;
         }
     }
     if ($this->_id && $this->_update_reference) {
         $ref = $this->loadReference();
         $ref->price = $this->unit_price;
         if ($msg = $ref->store()) {
             CAppUI::setMsg($msg, UI_MSG_WARNING);
         } else {
             CAppUI::setMsg('Prix de la référence mis à jour', UI_MSG_OK);
         }
         $this->_update_reference = null;
     }
     /*if (!$this->_id && ($stock = $this->getStock())) {
         $stock->loadRefOrders();
         if ($stock->_zone_future > 2) {
           CAppUI::setMsg("Attention : le stock optimum risque d'être dépassé", UI_MSG_WARNING);
         }
       }*/
     return parent::store();
 }