/**
  * add one record
  *
  * @param   Tinebase_Record_Interface $_record
  * @return  Sales_Model_Contract
  */
 public function create(Tinebase_Record_Interface $_record)
 {
     if (Sales_Config::getInstance()->get(Sales_Config::PRODUCT_NUMBER_GENERATION) == 'auto') {
         // add number if configured auto
         $this->_addNextNumber($_record);
     } else {
         // check uniquity if not autogenerated
         $this->_checkNumberUniquity($_record, false);
     }
     // check type
     $this->_checkNumberType($_record);
     return parent::create($_record);
 }
 /**
  * delete linked objects (notes, relations, ...) of record
  *
  * @param Tinebase_Record_Interface $_record
  */
 protected function _deleteLinkedObjects(Tinebase_Record_Interface $_record)
 {
     // use textfilter for contract_id
     $filter = new Sales_Model_ProductAggregateFilter(array());
     $filter->addFilter(new Tinebase_Model_Filter_Text(array('field' => 'contract_id', 'operator' => 'equals', 'value' => $_record->getId())));
     Sales_Controller_ProductAggregate::getInstance()->deleteByFilter($filter);
     parent::_deleteLinkedObjects($_record);
 }