diff --git a/htdocs/admin/index.php b/htdocs/admin/index.php
index 7dcc5a356b5..affedf1f43c 100644
--- a/htdocs/admin/index.php
+++ b/htdocs/admin/index.php
@@ -112,8 +112,8 @@ $reshook = $hookmanager->executeHooks('addHomeSetup', $parameters, $object, $act
print $hookmanager->resPrint;
if (empty($reshook)) {
// Show into other
- print ''.$langs->trans("SetupDescription5")." ";
- print " ";
+ print ''.$langs->trans("SetupDescription5")." ";
+ print ' ';
// Show logo
print '
';
diff --git a/htdocs/contact/class/contact.class.php b/htdocs/contact/class/contact.class.php
index e03010cb5a5..1aecac97f19 100644
--- a/htdocs/contact/class/contact.class.php
+++ b/htdocs/contact/class/contact.class.php
@@ -165,7 +165,8 @@ class Contact extends CommonObject
/**
* @var int Thirdparty ID
*/
- public $socid;
+ public $socid; // both socid and fk_soc are used
+ public $fk_soc; // both socid and fk_soc are used
/**
* @var int 0=inactive, 1=active
@@ -1027,7 +1028,8 @@ class Contact extends CommonObject
$this->country_code = $obj->country_id ? $obj->country_code : '';
$this->country = $obj->country_id ? ($langs->trans('Country'.$obj->country_code) != 'Country'.$obj->country_code ? $langs->transnoentities('Country'.$obj->country_code) : $obj->country) : '';
- $this->socid = $obj->fk_soc;
+ $this->fk_soc = $obj->fk_soc; // Both fk_soc and socid are used
+ $this->socid = $obj->fk_soc; // Both fk_soc and socid are used
$this->socname = $obj->socname;
$this->poste = $obj->poste;
$this->statut = $obj->statut;
diff --git a/htdocs/core/modules/bom/doc/doc_generic_bom_odt.modules.php b/htdocs/core/modules/bom/doc/doc_generic_bom_odt.modules.php
index 2e1ab3b5ef4..08d31e3cd95 100644
--- a/htdocs/core/modules/bom/doc/doc_generic_bom_odt.modules.php
+++ b/htdocs/core/modules/bom/doc/doc_generic_bom_odt.modules.php
@@ -295,12 +295,14 @@ class doc_generic_bom_odt extends ModelePDFBom
// Recipient name
$contactobject = null;
if (!empty($usecontact)) {
- // On peut utiliser le nom de la societe du contact
- if ($usecontact && ($object->contact->fk_soc != $object->thirdparty->id && (!isset($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT) || !empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)))) {
- $socobject = $object->contact;
+ // We can use the company of contact instead of thirdparty company
+ if ($object->contact->socid != $object->thirdparty->id && (!isset($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT) || !empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT))) {
+ $object->contact->fetch_thirdparty();
+ $socobject = $object->contact->thirdparty;
+ $contactobject = $object->contact;
} else {
$socobject = $object->thirdparty;
- // if we have a CUSTOMER contact and we dont use as recipient we store the contact object for later use
+ // if we have a CUSTOMER contact and we dont use it as thirdparty recipient we store the contact object for later use
$contactobject = $object->contact;
}
} else {
diff --git a/htdocs/core/modules/commande/doc/doc_generic_order_odt.modules.php b/htdocs/core/modules/commande/doc/doc_generic_order_odt.modules.php
index adb26a38e0a..1e6aeac79e5 100644
--- a/htdocs/core/modules/commande/doc/doc_generic_order_odt.modules.php
+++ b/htdocs/core/modules/commande/doc/doc_generic_order_odt.modules.php
@@ -53,7 +53,8 @@ class doc_generic_order_odt extends ModelePDFCommandes
public $phpmin = array(5, 6);
/**
- * @var string Dolibarr version of the loaded document
+ * Dolibarr version of the loaded document
+ * @var string
*/
public $version = 'dolibarr';
@@ -96,7 +97,7 @@ class doc_generic_order_odt extends ModelePDFCommandes
$this->option_freetext = 1; // Support add of a personalised text
$this->option_draft_watermark = 0; // Support add of a watermark on drafts
- // Recupere emetteur
+ // Get source company
$this->emetteur = $mysoc;
if (!$this->emetteur->country_code) {
$this->emetteur->country_code = substr($langs->defaultlang, -2); // By default if not defined
@@ -234,6 +235,7 @@ class doc_generic_order_odt extends ModelePDFCommandes
$sav_charset_output = $outputlangs->charset_output;
$outputlangs->charset_output = 'UTF-8';
+ // Load translation files required by the page
$outputlangs->loadLangs(array("main", "dict", "companies", "bills"));
if ($conf->commande->dir_output) {
@@ -271,7 +273,7 @@ class doc_generic_order_odt extends ModelePDFCommandes
$newfiletmp = preg_replace('/template_/i', '', $newfiletmp);
$newfiletmp = preg_replace('/modele_/i', '', $newfiletmp);
$newfiletmp = $objectref.'_'.$newfiletmp;
- //$file=$dir.'/'.$newfiletmp.'.'.dol_print_date(dol_now(),'%Y%m%d%H%M%S').'.odt';
+
// Get extension (ods or odt)
$newfileformat = substr($newfile, strrpos($newfile, '.') + 1);
if (!empty($conf->global->MAIN_DOC_USE_TIMING)) {
@@ -307,11 +309,14 @@ class doc_generic_order_odt extends ModelePDFCommandes
// Recipient name
$contactobject = null;
if (!empty($usecontact)) {
- if ($usecontact && ($object->contact->fk_soc != $object->thirdparty->id && (!isset($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT) || !empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)))) {
- $socobject = $object->contact;
+ // We can use the company of contact instead of thirdparty company
+ if ($object->contact->socid != $object->thirdparty->id && (!isset($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT) || !empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT))) {
+ $object->contact->fetch_thirdparty();
+ $socobject = $object->contact->thirdparty;
+ $contactobject = $object->contact;
} else {
$socobject = $object->thirdparty;
- // if we have a CUSTOMER contact and we dont use as recipient we store the contact object for later use
+ // if we have a CUSTOMER contact and we dont use it as thirdparty recipient we store the contact object for later use
$contactobject = $object->contact;
}
} else {
@@ -379,6 +384,7 @@ class doc_generic_order_odt extends ModelePDFCommandes
$array_other = $this->get_substitutionarray_other($outputlangs);
// retrieve contact information for use in object as contact_xxx tags
$array_thirdparty_contact = array();
+
if ($usecontact && is_object($contactobject)) {
$array_thirdparty_contact = $this->get_substitutionarray_contact($contactobject, $outputlangs, 'contact');
}
@@ -455,7 +461,6 @@ class doc_generic_order_odt extends ModelePDFCommandes
}
// Call the beforeODTSave hook
-
$parameters = array('odfHandler'=>&$odfHandler, 'file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs, 'substitutionarray'=>&$tmparray);
$reshook = $hookmanager->executeHooks('beforeODTSave', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
diff --git a/htdocs/core/modules/commande/doc/pdf_einstein.modules.php b/htdocs/core/modules/commande/doc/pdf_einstein.modules.php
index 561064aa86c..105c49b4fd1 100644
--- a/htdocs/core/modules/commande/doc/pdf_einstein.modules.php
+++ b/htdocs/core/modules/commande/doc/pdf_einstein.modules.php
@@ -1452,7 +1452,7 @@ class pdf_einstein extends ModelePDFCommandes
}
// Recipient name
- if ($usecontact && ($object->contact->fk_soc != $object->thirdparty->id && (!isset($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT) || !empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)))) {
+ if ($usecontact && ($object->contact->socid != $object->thirdparty->id && (!isset($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT) || !empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)))) {
$thirdparty = $object->contact;
} else {
$thirdparty = $object->thirdparty;
diff --git a/htdocs/core/modules/commande/doc/pdf_eratosthene.modules.php b/htdocs/core/modules/commande/doc/pdf_eratosthene.modules.php
index 99d32988b54..3fde2cc1646 100644
--- a/htdocs/core/modules/commande/doc/pdf_eratosthene.modules.php
+++ b/htdocs/core/modules/commande/doc/pdf_eratosthene.modules.php
@@ -1637,7 +1637,7 @@ class pdf_eratosthene extends ModelePDFCommandes
}
//Recipient name
- if ($usecontact && ($object->contact->fk_soc != $object->thirdparty->id && (!isset($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT) || !empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)))) {
+ if ($usecontact && ($object->contact->socid != $object->thirdparty->id && (!isset($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT) || !empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)))) {
$thirdparty = $object->contact;
} else {
$thirdparty = $object->thirdparty;
diff --git a/htdocs/core/modules/contract/doc/doc_generic_contract_odt.modules.php b/htdocs/core/modules/contract/doc/doc_generic_contract_odt.modules.php
index b1e441175d9..a640d342ddc 100644
--- a/htdocs/core/modules/contract/doc/doc_generic_contract_odt.modules.php
+++ b/htdocs/core/modules/contract/doc/doc_generic_contract_odt.modules.php
@@ -295,11 +295,14 @@ class doc_generic_contract_odt extends ModelePDFContract
// Recipient name
$contactobject = null;
if (!empty($usecontact)) {
- if ($usecontact && ($object->contact->fk_soc != $object->thirdparty->id && (!isset($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT) || !empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)))) {
- $socobject = $object->contact;
+ // We can use the company of contact instead of thirdparty company
+ if ($object->contact->socid != $object->thirdparty->id && (!isset($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT) || !empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT))) {
+ $object->contact->fetch_thirdparty();
+ $socobject = $object->contact->thirdparty;
+ $contactobject = $object->contact;
} else {
$socobject = $object->thirdparty;
- // if we have a CUSTOMER contact and we dont use as recipient we store the contact object for later use
+ // if we have a CUSTOMER contact and we dont use it as thirdparty recipient we store the contact object for later use
$contactobject = $object->contact;
}
} else {
diff --git a/htdocs/core/modules/contract/doc/pdf_strato.modules.php b/htdocs/core/modules/contract/doc/pdf_strato.modules.php
index 638c22221bd..69a4d5ce96e 100644
--- a/htdocs/core/modules/contract/doc/pdf_strato.modules.php
+++ b/htdocs/core/modules/contract/doc/pdf_strato.modules.php
@@ -720,7 +720,7 @@ class pdf_strato extends ModelePDFContract
$this->recipient = $object->thirdparty;
// Recipient name
- if ($usecontact && ($object->contact->fk_soc != $object->thirdparty->id && (!isset($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT) || !empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)))) {
+ if ($usecontact && ($object->contact->socid != $object->thirdparty->id && (!isset($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT) || !empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)))) {
$thirdparty = $object->contact;
} else {
$thirdparty = $object->thirdparty;
diff --git a/htdocs/core/modules/delivery/doc/pdf_storm.modules.php b/htdocs/core/modules/delivery/doc/pdf_storm.modules.php
index 2893234e719..9c549576818 100644
--- a/htdocs/core/modules/delivery/doc/pdf_storm.modules.php
+++ b/htdocs/core/modules/delivery/doc/pdf_storm.modules.php
@@ -860,7 +860,7 @@ class pdf_storm extends ModelePDFDeliveryOrder
}
// Recipient name
- if ($usecontact && ($object->contact->fk_soc != $object->thirdparty->id && (!isset($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT) || !empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)))) {
+ if ($usecontact && ($object->contact->socid != $object->thirdparty->id && (!isset($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT) || !empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)))) {
$thirdparty = $object->contact;
} else {
$thirdparty = $object->thirdparty;
diff --git a/htdocs/core/modules/delivery/doc/pdf_typhon.modules.php b/htdocs/core/modules/delivery/doc/pdf_typhon.modules.php
index 4656784f50d..19e319d0522 100644
--- a/htdocs/core/modules/delivery/doc/pdf_typhon.modules.php
+++ b/htdocs/core/modules/delivery/doc/pdf_typhon.modules.php
@@ -859,7 +859,7 @@ class pdf_typhon extends ModelePDFDeliveryOrder
}
// Recipient name
- if ($usecontact && ($object->contact->fk_soc != $object->thirdparty->id && (!isset($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT) || !empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)))) {
+ if ($usecontact && ($object->contact->socid != $object->thirdparty->id && (!isset($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT) || !empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)))) {
$thirdparty = $object->contact;
} else {
$thirdparty = $object->thirdparty;
diff --git a/htdocs/core/modules/expedition/doc/doc_generic_shipment_odt.modules.php b/htdocs/core/modules/expedition/doc/doc_generic_shipment_odt.modules.php
index 5229645afe5..c504d97a854 100644
--- a/htdocs/core/modules/expedition/doc/doc_generic_shipment_odt.modules.php
+++ b/htdocs/core/modules/expedition/doc/doc_generic_shipment_odt.modules.php
@@ -307,11 +307,14 @@ class doc_generic_shipment_odt extends ModelePdfExpedition
// Recipient name
$contactobject = null;
if (!empty($usecontact)) {
- if ($usecontact && ($object->contact->fk_soc != $object->thirdparty->id && (!isset($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT) || !empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)))) {
- $socobject = $object->contact;
+ // We can use the company of contact instead of thirdparty company
+ if ($object->contact->socid != $object->thirdparty->id && (!isset($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT) || !empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT))) {
+ $object->contact->fetch_thirdparty();
+ $socobject = $object->contact->thirdparty;
+ $contactobject = $object->contact;
} else {
$socobject = $object->thirdparty;
- // if we have a SHIPPING contact and we dont use as recipient we store the contact object for later use
+ // if we have a SHIPPING contact and we dont use it as thirdparty recipient we store the contact object for later use
$contactobject = $object->contact;
}
} else {
diff --git a/htdocs/core/modules/expedition/doc/pdf_espadon.modules.php b/htdocs/core/modules/expedition/doc/pdf_espadon.modules.php
index 28d797acffc..6488773d240 100644
--- a/htdocs/core/modules/expedition/doc/pdf_espadon.modules.php
+++ b/htdocs/core/modules/expedition/doc/pdf_espadon.modules.php
@@ -1121,7 +1121,7 @@ class pdf_espadon extends ModelePdfExpedition
}
// Recipient name
- if ($usecontact && ($object->contact->fk_soc != $object->thirdparty->id && (!isset($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT) || !empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)))) {
+ if ($usecontact && ($object->contact->socid != $object->thirdparty->id && (!isset($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT) || !empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)))) {
$thirdparty = $object->contact;
} else {
$thirdparty = $object->thirdparty;
diff --git a/htdocs/core/modules/expedition/doc/pdf_merou.modules.php b/htdocs/core/modules/expedition/doc/pdf_merou.modules.php
index f2434c93d26..56c8fb143fb 100644
--- a/htdocs/core/modules/expedition/doc/pdf_merou.modules.php
+++ b/htdocs/core/modules/expedition/doc/pdf_merou.modules.php
@@ -676,7 +676,7 @@ class pdf_merou extends ModelePdfExpedition
}
// Recipient name
- if ($usecontact && ($object->contact->fk_soc != $object->thirdparty->id && (!isset($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT) || !empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)))) {
+ if ($usecontact && ($object->contact->socid != $object->thirdparty->id && (!isset($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT) || !empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)))) {
$thirdparty = $object->contact;
} else {
$thirdparty = $object->thirdparty;
diff --git a/htdocs/core/modules/expedition/doc/pdf_rouget.modules.php b/htdocs/core/modules/expedition/doc/pdf_rouget.modules.php
index aa6603fa35a..4b542e4e636 100644
--- a/htdocs/core/modules/expedition/doc/pdf_rouget.modules.php
+++ b/htdocs/core/modules/expedition/doc/pdf_rouget.modules.php
@@ -1071,7 +1071,7 @@ class pdf_rouget extends ModelePdfExpedition
}
// Recipient name
- if ($usecontact && ($object->contact->fk_soc != $object->thirdparty->id && (!isset($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT) || !empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)))) {
+ if ($usecontact && ($object->contact->socid != $object->thirdparty->id && (!isset($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT) || !empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)))) {
$thirdparty = $object->contact;
} else {
$thirdparty = $object->thirdparty;
diff --git a/htdocs/core/modules/facture/doc/doc_generic_invoice_odt.modules.php b/htdocs/core/modules/facture/doc/doc_generic_invoice_odt.modules.php
index ec494302e93..ef20b4ff389 100644
--- a/htdocs/core/modules/facture/doc/doc_generic_invoice_odt.modules.php
+++ b/htdocs/core/modules/facture/doc/doc_generic_invoice_odt.modules.php
@@ -308,11 +308,14 @@ class doc_generic_invoice_odt extends ModelePDFFactures
// Recipient name
$contactobject = null;
if (!empty($usecontact)) {
- if ($usecontact && ($object->contact->fk_soc != $object->thirdparty->id && (!isset($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT) || !empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)))) {
- $socobject = $object->contact;
+ // We can use the company of contact instead of thirdparty company
+ if ($object->contact->socid != $object->thirdparty->id && (!isset($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT) || !empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT))) {
+ $object->contact->fetch_thirdparty();
+ $socobject = $object->contact->thirdparty;
+ $contactobject = $object->contact;
} else {
$socobject = $object->thirdparty;
- // if we have a BILLING contact and we dont use it as recipient we store the contact object for later use
+ // if we have a BILLING contact and we dont use it as thirdparty recipient we store the contact object for later use
$contactobject = $object->contact;
}
} else {
diff --git a/htdocs/core/modules/facture/doc/pdf_crabe.modules.php b/htdocs/core/modules/facture/doc/pdf_crabe.modules.php
index 0fe149af0df..037074bce23 100644
--- a/htdocs/core/modules/facture/doc/pdf_crabe.modules.php
+++ b/htdocs/core/modules/facture/doc/pdf_crabe.modules.php
@@ -1927,7 +1927,7 @@ class pdf_crabe extends ModelePDFFactures
}
// Recipient name
- if ($usecontact && ($object->contact->fk_soc != $object->thirdparty->id && (!isset($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT) || !empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)))) {
+ if ($usecontact && ($object->contact->socid != $object->thirdparty->id && (!isset($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT) || !empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)))) {
$thirdparty = $object->contact;
} else {
$thirdparty = $object->thirdparty;
diff --git a/htdocs/core/modules/facture/doc/pdf_sponge.modules.php b/htdocs/core/modules/facture/doc/pdf_sponge.modules.php
index 021f195c577..b919b90abfd 100644
--- a/htdocs/core/modules/facture/doc/pdf_sponge.modules.php
+++ b/htdocs/core/modules/facture/doc/pdf_sponge.modules.php
@@ -2143,7 +2143,7 @@ class pdf_sponge extends ModelePDFFactures
}
// Recipient name
- if ($usecontact && ($object->contact->fk_soc != $object->thirdparty->id && (!isset($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT) || !empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)))) {
+ if ($usecontact && ($object->contact->socid != $object->thirdparty->id && (!isset($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT) || !empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)))) {
$thirdparty = $object->contact;
} else {
$thirdparty = $object->thirdparty;
diff --git a/htdocs/core/modules/fichinter/doc/pdf_soleil.modules.php b/htdocs/core/modules/fichinter/doc/pdf_soleil.modules.php
index 37d64c43e17..e23a0aa1701 100644
--- a/htdocs/core/modules/fichinter/doc/pdf_soleil.modules.php
+++ b/htdocs/core/modules/fichinter/doc/pdf_soleil.modules.php
@@ -674,7 +674,7 @@ class pdf_soleil extends ModelePDFFicheinter
}
// Recipient name
- if ($usecontact && ($object->contact->fk_soc != $object->thirdparty->id && (!isset($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT) || !empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)))) {
+ if ($usecontact && ($object->contact->socid != $object->thirdparty->id && (!isset($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT) || !empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)))) {
$thirdparty = $object->contact;
} else {
$thirdparty = $object->thirdparty;
diff --git a/htdocs/core/modules/member/doc/doc_generic_member_odt.class.php b/htdocs/core/modules/member/doc/doc_generic_member_odt.class.php
index 7b2af1e0032..6ba84727b3f 100644
--- a/htdocs/core/modules/member/doc/doc_generic_member_odt.class.php
+++ b/htdocs/core/modules/member/doc/doc_generic_member_odt.class.php
@@ -295,11 +295,14 @@ class doc_generic_member_odt extends ModelePDFMember
// Recipient name
if (!empty($usecontact)) {
- if ($usecontact && ($object->contact->fk_soc != $object->thirdparty->id && (!isset($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT) || !empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)))) {
- $socobject = $object->contact;
+ // We can use the company of contact instead of thirdparty company
+ if ($object->contact->socid != $object->thirdparty->id && (!isset($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT) || !empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT))) {
+ $object->contact->fetch_thirdparty();
+ $socobject = $object->contact->thirdparty;
+ $contactobject = $object->contact;
} else {
$socobject = $object->thirdparty;
- // if we have a CUSTOMER contact and we dont use it as recipient we store the contact object for later use
+ // if we have a CUSTOMER contact and we dont use it as thirdparty recipient we store the contact object for later use
$contactobject = $object->contact;
}
} else {
diff --git a/htdocs/core/modules/mrp/doc/doc_generic_mo_odt.modules.php b/htdocs/core/modules/mrp/doc/doc_generic_mo_odt.modules.php
index b6ad4c6b8ff..c2d697b4a4d 100644
--- a/htdocs/core/modules/mrp/doc/doc_generic_mo_odt.modules.php
+++ b/htdocs/core/modules/mrp/doc/doc_generic_mo_odt.modules.php
@@ -302,11 +302,14 @@ class doc_generic_mo_odt extends ModelePDFMo
// Recipient name
$contactobject = null;
if (!empty($usecontact)) {
- if ($usecontact && ($object->contact->fk_soc != $object->thirdparty->id && (!isset($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT) || !empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)))) {
- $socobject = $object->contact;
+ // We can use the company of contact instead of thirdparty company
+ if ($object->contact->socid != $object->thirdparty->id && (!isset($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT) || !empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT))) {
+ $object->contact->fetch_thirdparty();
+ $socobject = $object->contact->thirdparty;
+ $contactobject = $object->contact;
} else {
$socobject = $object->thirdparty;
- // if we have a CUSTOMER contact and we dont use it as recipient we store the contact object for later use
+ // if we have a CUSTOMER contact and we dont use it as thirdparty recipient we store the contact object for later use
$contactobject = $object->contact;
}
} else {
diff --git a/htdocs/core/modules/product/doc/doc_generic_product_odt.modules.php b/htdocs/core/modules/product/doc/doc_generic_product_odt.modules.php
index 05eef305c37..d702299769e 100644
--- a/htdocs/core/modules/product/doc/doc_generic_product_odt.modules.php
+++ b/htdocs/core/modules/product/doc/doc_generic_product_odt.modules.php
@@ -118,15 +118,10 @@ class doc_generic_product_odt extends ModelePDFProduct
$form = new Form($this->db);
$texte = $this->description.". \n";
- $texte .= '