Fix: missing linked objects

This commit is contained in:
Regis Houssin 2012-03-15 07:23:49 +01:00
parent 942b1f2a19
commit e86fed02fc
3 changed files with 26 additions and 7 deletions

View File

@ -2004,6 +2004,7 @@ else
} }
$db->close(); // End of page
llxFooter(); llxFooter();
$db->close();
?> ?>

View File

@ -868,6 +868,7 @@ class Commande extends CommonObject
function createFromProposal($object) function createFromProposal($object)
{ {
global $conf,$user,$langs; global $conf,$user,$langs;
global $hookmanager;
$error=0; $error=0;
@ -915,16 +916,26 @@ class Commande extends CommonObject
$this->note = $object->note; $this->note = $object->note;
$this->note_public = $object->note_public; $this->note_public = $object->note_public;
$this->origin = $object->element; $this->origin = $object->element;
$this->origin_id = $object->id; $this->origin_id = $object->id;
// Possibility to add external linked objects with hooks
$this->linked_objects[$this->origin] = $this->origin_id;
if (is_array($object->other_linked_objects) && ! empty($object->other_linked_objects))
{
$this->linked_objects = array_merge($this->linked_objects, $object->other_linked_objects);
}
$ret = $this->create($user); $ret = $this->create($user);
if ($ret > 0) if ($ret > 0)
{ {
// Actions hooked (by external module) // Actions hooked (by external module)
include_once(DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'); if (! is_object($hookmanager))
$hookmanager=new HookManager($this->db); {
include_once(DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php');
$hookmanager=new HookManager($this->db);
}
$hookmanager->initHooks(array('orderdao')); $hookmanager->initHooks(array('orderdao'));
$parameters=array('objFrom'=>$object); $parameters=array('objFrom'=>$object);

View File

@ -669,8 +669,15 @@ class Facture extends CommonObject
$this->note = $object->note; $this->note = $object->note;
$this->note_public = $object->note_public; $this->note_public = $object->note_public;
$this->origin = $object->element; $this->origin = $object->element;
$this->origin_id = $object->id; $this->origin_id = $object->id;
// Possibility to add external linked objects with hooks
$this->linked_objects[$this->origin] = $this->origin_id;
if (is_array($object->other_linked_objects) && ! empty($object->other_linked_objects))
{
$this->linked_objects = array_merge($this->linked_objects, $object->other_linked_objects);
}
$ret = $this->create($user); $ret = $this->create($user);