Fix: missing contacts with order to invoice

This commit is contained in:
Regis Houssin 2012-03-11 11:34:20 +01:00
parent a5482c56ab
commit 19d4147fcd
2 changed files with 50 additions and 25 deletions

View File

@ -700,15 +700,14 @@ class Commande extends CommonObject
{ {
$this->ref="(PROV".$this->id.")"; $this->ref="(PROV".$this->id.")";
// Add linked object // Add linked object and contacts
if ($this->origin && $this->origin_id) if ($this->origin && $this->origin_id)
{ {
$ret = $this->add_object_linked(); $ret = $this->add_object_linked();
if (! $ret) dol_print_error($this->db); if (! $ret) dol_print_error($this->db);
}
// TODO mutualiser // TODO mutualiser
if ($this->origin == 'propal' && $this->origin_id) if ($this->origin == 'propal')
{ {
// On recupere les differents contact interne et externe // On recupere les differents contact interne et externe
$prop = new Propal($this->db, $this->socid, $this->origin_id); $prop = new Propal($this->db, $this->socid, $this->origin_id);
@ -732,6 +731,7 @@ class Commande extends CommonObject
} }
} }
} }
}
if (! $notrigger) if (! $notrigger)
{ {

View File

@ -275,6 +275,31 @@ class Facture extends CommonObject
dol_print_error($this->db); dol_print_error($this->db);
$error++; $error++;
} }
// TODO mutualiser
if ($this->origin == 'commande')
{
// On recupere les differents contact interne et externe
$order = new Commande($this->db, $this->socid, $this->origin_id);
// On recupere le commercial suivi propale
$this->userid = $order->getIdcontact('internal', 'SALESREPFOLL');
if ($this->userid)
{
//On passe le commercial suivi commande en commercial suivi paiement
$this->add_contact($this->userid[0], 'SALESREPFOLL', 'internal');
}
// On recupere le contact client facturation commande
$this->contactid = $order->getIdcontact('external', 'BILLING');
if ($this->contactid)
{
//On passe le contact client facturation commande en contact client facturation
$this->add_contact($this->contactid[0], 'BILLING', 'external');
}
}
} }
/* /*