diff --git a/htdocs/asset/tpl/linkedobjectblock.tpl.php b/htdocs/asset/tpl/linkedobjectblock.tpl.php index aef30995432..11d94714db8 100644 --- a/htdocs/asset/tpl/linkedobjectblock.tpl.php +++ b/htdocs/asset/tpl/linkedobjectblock.tpl.php @@ -46,12 +46,12 @@ foreach ($linkedObjectBlock as $key => $objectlink) { $trclass .= ' liste_sub_total'; } echo ''; - echo ''.$langs->trans("Asset"); + echo ''.$langs->trans("Asset"); if (!empty($showImportButton) && !empty($conf->global->MAIN_ENABLE_IMPORT_LINKED_OBJECT_LINES)) { print ' '; - echo ''.$objectlink->getNomUrl(1).''; + echo ''.$objectlink->getNomUrl(1).''; echo ''.$objectlink->label.''; echo ''.dol_print_date($objectlink->date_start, 'day').''; echo ''; diff --git a/htdocs/bom/tpl/linkedobjectblock.tpl.php b/htdocs/bom/tpl/linkedobjectblock.tpl.php index 8a98c078bc5..1765e9a84c1 100644 --- a/htdocs/bom/tpl/linkedobjectblock.tpl.php +++ b/htdocs/bom/tpl/linkedobjectblock.tpl.php @@ -47,12 +47,12 @@ foreach ($linkedObjectBlock as $key => $objectlink) { $trclass .= ' liste_sub_total'; } echo ''; - echo ''.$langs->trans("Bom"); + echo ''.$langs->trans("Bom"); if (!empty($showImportButton) && $conf->global->MAIN_ENABLE_IMPORT_LINKED_OBJECT_LINES) { print ' '; - echo ''.$objectlink->getNomUrl(1).''; + echo ''.$objectlink->getNomUrl(1).''; echo ''; $result = $product_static->fetch($objectlink->fk_product); diff --git a/htdocs/comm/propal/tpl/linkedobjectblock.tpl.php b/htdocs/comm/propal/tpl/linkedobjectblock.tpl.php index 37c0f8d5e58..8aa72d9c43f 100644 --- a/htdocs/comm/propal/tpl/linkedobjectblock.tpl.php +++ b/htdocs/comm/propal/tpl/linkedobjectblock.tpl.php @@ -52,13 +52,13 @@ foreach ($linkedObjectBlock as $key => $objectlink) { $trclass .= ' liste_sub_total'; } print ''; - print ''.$langs->trans("Proposal"); + print ''.$langs->trans("Proposal"); if (!empty($showImportButton) && $conf->global->MAIN_ENABLE_IMPORT_LINKED_OBJECT_LINES) { $url = DOL_URL_ROOT.'/comm/propal/card.php?id='.$objectlink->id; print ' '; } print ''; - print ''.$objectlink->getNomUrl(1).''; + print ''.$objectlink->getNomUrl(1).''; print ''.$objectlink->ref_client.''; print ''.dol_print_date($objectlink->date, 'day').''; print ''; diff --git a/htdocs/commande/tpl/linkedobjectblock.tpl.php b/htdocs/commande/tpl/linkedobjectblock.tpl.php index 819a6ecb74f..a6a1fde3851 100644 --- a/htdocs/commande/tpl/linkedobjectblock.tpl.php +++ b/htdocs/commande/tpl/linkedobjectblock.tpl.php @@ -46,12 +46,12 @@ foreach ($linkedObjectBlock as $key => $objectlink) { $trclass .= ' liste_sub_total'; } echo ''; - echo ''.$langs->trans("CustomerOrder"); + echo ''.$langs->trans("CustomerOrder"); if (!empty($showImportButton) && !empty($conf->global->MAIN_ENABLE_IMPORT_LINKED_OBJECT_LINES)) { print ' '; - echo ''.$objectlink->getNomUrl(1).''; + echo ''.$objectlink->getNomUrl(1).''; echo ''.$objectlink->ref_client.''; echo ''.dol_print_date($objectlink->date, 'day').''; echo ''; diff --git a/htdocs/compta/facture/tpl/linkedobjectblock.tpl.php b/htdocs/compta/facture/tpl/linkedobjectblock.tpl.php index 6a16f4fa641..ca782052ff4 100644 --- a/htdocs/compta/facture/tpl/linkedobjectblock.tpl.php +++ b/htdocs/compta/facture/tpl/linkedobjectblock.tpl.php @@ -67,7 +67,7 @@ foreach ($linkedObjectBlock as $key => $objectlink) { break; } print ''; - print ''.$objectlink->getNomUrl(1).''; + print ''.$objectlink->getNomUrl(1).''; print ''.dol_escape_htmltag($objectlink->ref_client).''; print ''.dol_print_date($objectlink->date, 'day').''; print ''; diff --git a/htdocs/compta/facture/tpl/linkedobjectblockForRec.tpl.php b/htdocs/compta/facture/tpl/linkedobjectblockForRec.tpl.php index 1bca663e1ef..c3c774b79e7 100644 --- a/htdocs/compta/facture/tpl/linkedobjectblockForRec.tpl.php +++ b/htdocs/compta/facture/tpl/linkedobjectblockForRec.tpl.php @@ -47,7 +47,7 @@ foreach ($linkedObjectBlock as $key => $objectlink) { ?> trans("RepeatableInvoice"); ?> - getNomUrl(1); ?> + getNomUrl(1); ?> date_when, 'day'); ?> 0 if OK + * @see fetchObjectLinked() + */ + public function clearObjectLinkedCache() + { + if ($this->id > 0 && !empty($this->linkedObjectsFullLoaded[$this->id])) { + unset($this->linkedObjectsFullLoaded[$this->id]); + } + + return 1; + } + /** * Update object linked of a current object * diff --git a/htdocs/core/triggers/interface_20_modWorkflow_WorkflowManager.class.php b/htdocs/core/triggers/interface_20_modWorkflow_WorkflowManager.class.php index abaadfc85a8..b6bd9bb73a8 100644 --- a/htdocs/core/triggers/interface_20_modWorkflow_WorkflowManager.class.php +++ b/htdocs/core/triggers/interface_20_modWorkflow_WorkflowManager.class.php @@ -90,6 +90,9 @@ class InterfaceWorkflowManager extends DolibarrTriggers $this->error = $newobject->error; $this->errors[] = $newobject->error; } + + $object->clearObjectLinkedCache(); + return $ret; } } @@ -111,6 +114,9 @@ class InterfaceWorkflowManager extends DolibarrTriggers $this->error = $newobject->error; $this->errors[] = $newobject->error; } + + $object->clearObjectLinkedCache(); + return $ret; } } diff --git a/htdocs/modulebuilder/template/myobject_note.php b/htdocs/modulebuilder/template/myobject_note.php index 89e5e0ba76e..1f3bf7c9fd4 100644 --- a/htdocs/modulebuilder/template/myobject_note.php +++ b/htdocs/modulebuilder/template/myobject_note.php @@ -96,7 +96,7 @@ $extrafields->fetch_name_optionals_label($object->table_element); // Load object include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once // Must be include, not include_once. Include fetch and fetch_thirdparty but not fetch_optionals if ($id > 0 || !empty($ref)) { - $upload_dir = $conf->mymodule->multidir_output[!empty($object->entity) ? $object->entity : $conf->entity]."/".$object->id; + $upload_dir = $conf->mymodule->multidir_output[empty($object->entity) ? $conf->entity : $object->entity]."/".$object->id; } diff --git a/htdocs/mrp/class/mo.class.php b/htdocs/mrp/class/mo.class.php index 8624713c689..13f7cc5ae7b 100644 --- a/htdocs/mrp/class/mo.class.php +++ b/htdocs/mrp/class/mo.class.php @@ -131,6 +131,7 @@ class Mo extends CommonObject public $qty; public $fk_warehouse; public $fk_soc; + public $socid; /** * @var string public note @@ -406,6 +407,9 @@ class Mo extends CommonObject if ($result > 0 && !empty($this->table_element_line)) { $this->fetchLines(); } + + $this->socid = $this->fk_soc; + return $result; } diff --git a/htdocs/mrp/mo_agenda.php b/htdocs/mrp/mo_agenda.php index dbba6ed912a..35e905cc2b5 100644 --- a/htdocs/mrp/mo_agenda.php +++ b/htdocs/mrp/mo_agenda.php @@ -151,14 +151,18 @@ if ($object->id > 0) { //$morehtmlref.=$form->editfieldkey("RefCustomer", 'ref_client', $object->ref_client, $object, 0, 'string', '', 0, 1); //$morehtmlref.=$form->editfieldval("RefCustomer", 'ref_client', $object->ref_client, $object, 0, 'string', '', null, null, '', 1); // Thirdparty - $morehtmlref .= $object->thirdparty->getNomUrl(1, 'customer'); - if (empty($conf->global->MAIN_DISABLE_OTHER_LINK) && $object->thirdparty->id > 0) { - $morehtmlref .= ' ('.$langs->trans("OtherOrders").')'; + if (is_object($object->thirdparty)) { + $morehtmlref .= $object->thirdparty->getNomUrl(1, 'customer'); + if (empty($conf->global->MAIN_DISABLE_OTHER_LINK) && $object->thirdparty->id > 0) { + $morehtmlref .= ' ('.$langs->trans("OtherOrders").')'; + } } // Project if (isModEnabled('project')) { $langs->load("projects"); - $morehtmlref .= '
'; + if (is_object($object->thirdparty)) { + $morehtmlref .= '
'; + } if (0) { $morehtmlref .= img_picto($langs->trans("Project"), 'project', 'class="pictofixedwidth"'); if ($action != 'classify') { diff --git a/htdocs/mrp/mo_card.php b/htdocs/mrp/mo_card.php index 026267a2243..b1d12be0c8d 100644 --- a/htdocs/mrp/mo_card.php +++ b/htdocs/mrp/mo_card.php @@ -484,14 +484,18 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea $morehtmlref.=$form->editfieldkey("RefBis", 'ref_client', $object->ref_client, $object, $user->rights->mrp->creer, 'string', '', 0, 1); $morehtmlref.=$form->editfieldval("RefBis", 'ref_client', $object->ref_client, $object, $user->rights->mrp->creer, 'string', '', null, null, '', 1);*/ // Thirdparty - $morehtmlref .= $object->thirdparty->getNomUrl(1, 'customer'); - if (empty($conf->global->MAIN_DISABLE_OTHER_LINK) && $object->thirdparty->id > 0) { - $morehtmlref .= ' ('.$langs->trans("OtherOrders").')'; + if (is_object($object->thirdparty)) { + $morehtmlref .= $object->thirdparty->getNomUrl(1, 'customer'); + if (empty($conf->global->MAIN_DISABLE_OTHER_LINK) && $object->thirdparty->id > 0) { + $morehtmlref .= ' ('.$langs->trans("OtherOrders").')'; + } } // Project if (isModEnabled('project')) { $langs->load("projects"); - $morehtmlref .= '
'; + if (is_object($object->thirdparty)) { + $morehtmlref .= '
'; + } if ($permissiontoadd) { $morehtmlref .= img_picto($langs->trans("Project"), 'project', 'class="pictofixedwidth"'); if ($action != 'classify') { diff --git a/htdocs/mrp/mo_document.php b/htdocs/mrp/mo_document.php index 57998132a84..2f213b6b825 100644 --- a/htdocs/mrp/mo_document.php +++ b/htdocs/mrp/mo_document.php @@ -129,14 +129,18 @@ if ($object->id) { //$morehtmlref.=$form->editfieldkey("RefCustomer", 'ref_client', $object->ref_client, $object, 0, 'string', '', 0, 1); //$morehtmlref.=$form->editfieldval("RefCustomer", 'ref_client', $object->ref_client, $object, 0, 'string', '', null, null, '', 1); // Thirdparty - $morehtmlref .= $object->thirdparty->getNomUrl(1, 'customer'); - if (empty($conf->global->MAIN_DISABLE_OTHER_LINK) && $object->thirdparty->id > 0) { - $morehtmlref .= ' ('.$langs->trans("OtherOrders").')'; + if (is_object($object->thirdparty)) { + $morehtmlref .= $object->thirdparty->getNomUrl(1, 'customer'); + if (empty($conf->global->MAIN_DISABLE_OTHER_LINK) && $object->thirdparty->id > 0) { + $morehtmlref .= ' ('.$langs->trans("OtherOrders").')'; + } } // Project if (isModEnabled('project')) { $langs->load("projects"); - $morehtmlref .= '
'; + if (is_object($object->thirdparty)) { + $morehtmlref .= '
'; + } if (0) { $morehtmlref .= img_picto($langs->trans("Project"), 'project', 'class="pictofixedwidth"'); if ($action != 'classify') { diff --git a/htdocs/mrp/mo_movements.php b/htdocs/mrp/mo_movements.php index 96891186b3f..84c359cfc25 100644 --- a/htdocs/mrp/mo_movements.php +++ b/htdocs/mrp/mo_movements.php @@ -326,14 +326,18 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea $morehtmlref.=$form->editfieldkey("RefBis", 'ref_client', $object->ref_client, $object, $user->rights->mrp->creer, 'string', '', 0, 1); $morehtmlref.=$form->editfieldval("RefBis", 'ref_client', $object->ref_client, $object, $user->rights->mrp->creer, 'string', '', null, null, '', 1);*/ // Thirdparty - $morehtmlref .= $object->thirdparty->getNomUrl(1, 'customer'); - if (empty($conf->global->MAIN_DISABLE_OTHER_LINK) && $object->thirdparty->id > 0) { - $morehtmlref .= ' ('.$langs->trans("OtherOrders").')'; + if (is_object($object->thirdparty)) { + $morehtmlref .= $object->thirdparty->getNomUrl(1, 'customer'); + if (empty($conf->global->MAIN_DISABLE_OTHER_LINK) && $object->thirdparty->id > 0) { + $morehtmlref .= ' ('.$langs->trans("OtherOrders").')'; + } } // Project if (isModEnabled('project')) { $langs->load("projects"); - $morehtmlref .= '
'; + if (is_object($object->thirdparty)) { + $morehtmlref .= '
'; + } if ($permissiontoadd) { $morehtmlref .= img_picto($langs->trans("Project"), 'project', 'class="pictofixedwidth"'); if ($action != 'classify') { @@ -619,13 +623,13 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea if (!empty($arrayfields['p.ref']['checked'])) { // Product Ref print ''; - print ''; + print ''; print ''; } if (!empty($arrayfields['p.label']['checked'])) { // Product label print ''; - print ''; + print ''; print ''; } // Batch diff --git a/htdocs/mrp/mo_note.php b/htdocs/mrp/mo_note.php index 47a01f388a6..03a6fa7b487 100644 --- a/htdocs/mrp/mo_note.php +++ b/htdocs/mrp/mo_note.php @@ -51,7 +51,7 @@ $extrafields->fetch_name_optionals_label($object->table_element); // Load object include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once // Must be include, not include_once. Include fetch and fetch_thirdparty but not fetch_optionals if ($id > 0 || !empty($ref)) { - $upload_dir = $conf->mrp->multidir_output[$object->entity]."/".$object->id; + $upload_dir = $conf->mrp->multidir_output[empty($object->entity) ? $conf->entity : $object->entity]."/".$object->id; } // Security check - Protection if external user @@ -105,14 +105,18 @@ if ($id > 0 || !empty($ref)) { //$morehtmlref.=$form->editfieldkey("RefCustomer", 'ref_client', $object->ref_client, $object, 0, 'string', '', 0, 1); //$morehtmlref.=$form->editfieldval("RefCustomer", 'ref_client', $object->ref_client, $object, 0, 'string', '', null, null, '', 1); // Thirdparty - $morehtmlref .= $object->thirdparty->getNomUrl(1, 'customer'); - if (empty($conf->global->MAIN_DISABLE_OTHER_LINK) && $object->thirdparty->id > 0) { - $morehtmlref .= ' ('.$langs->trans("OtherOrders").')'; + if (is_object($object->thirdparty)) { + $morehtmlref .= $object->thirdparty->getNomUrl(1, 'customer'); + if (empty($conf->global->MAIN_DISABLE_OTHER_LINK) && $object->thirdparty->id > 0) { + $morehtmlref .= ' ('.$langs->trans("OtherOrders").')'; + } } // Project if (isModEnabled('project')) { $langs->load("projects"); - $morehtmlref .= '
'; + if (is_object($object->thirdparty)) { + $morehtmlref .= '
'; + } if (0) { $morehtmlref .= img_picto($langs->trans("Project"), 'project', 'class="pictofixedwidth"'); if ($action != 'classify') { diff --git a/htdocs/mrp/mo_production.php b/htdocs/mrp/mo_production.php index b5856b81a99..1f61bf37935 100644 --- a/htdocs/mrp/mo_production.php +++ b/htdocs/mrp/mo_production.php @@ -523,14 +523,18 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea $morehtmlref.=$form->editfieldkey("RefBis", 'ref_client', $object->ref_client, $object, $user->rights->mrp->creer, 'string', '', 0, 1); $morehtmlref.=$form->editfieldval("RefBis", 'ref_client', $object->ref_client, $object, $user->rights->mrp->creer, 'string', '', null, null, '', 1);*/ // Thirdparty - $morehtmlref .= $object->thirdparty->getNomUrl(1, 'customer'); - if (empty($conf->global->MAIN_DISABLE_OTHER_LINK) && $object->thirdparty->id > 0) { - $morehtmlref .= ' ('.$langs->trans("OtherOrders").')'; + if (is_object($object->thirdparty)) { + $morehtmlref .= $object->thirdparty->getNomUrl(1, 'customer'); + if (empty($conf->global->MAIN_DISABLE_OTHER_LINK) && $object->thirdparty->id > 0) { + $morehtmlref .= ' ('.$langs->trans("OtherOrders").')'; + } } // Project if (isModEnabled('project')) { $langs->load("projects"); - $morehtmlref .= '
'; + if (is_object($object->thirdparty)) { + $morehtmlref .= '
'; + } if ($permissiontoadd) { $morehtmlref .= img_picto($langs->trans("Project"), 'project', 'class="pictofixedwidth"'); if ($action != 'classify') { diff --git a/htdocs/mrp/tpl/linkedobjectblock.tpl.php b/htdocs/mrp/tpl/linkedobjectblock.tpl.php index 84ca487b771..ea8ed703481 100644 --- a/htdocs/mrp/tpl/linkedobjectblock.tpl.php +++ b/htdocs/mrp/tpl/linkedobjectblock.tpl.php @@ -54,17 +54,17 @@ if ($object->element == 'mo') { $trclass = 'oddeven'; echo ''; - echo '' . $langs->trans("ManufacturingOrder"); + echo '' . $langs->trans("ManufacturingOrder"); if (!empty($showImportButton) && $conf->global->MAIN_ENABLE_IMPORT_LINKED_OBJECT_LINES) { print ' '; echo '' . $objectlink->getNomUrl(1) . ''; - echo ''; + echo ''; // $result = $product_static->fetch($objectlink->fk_product); print ''; - echo '' . dol_print_date($objectlink->date_creation, 'day') . ''; + echo '' . dol_print_date($objectlink->date_creation, 'day') . ''; echo '-'; echo '' . $objectlink->getLibStatut(3) . ''; echo ''; @@ -97,14 +97,14 @@ if ($object->element == 'mo') { $trclass .= ' liste_sub_total'; } print ''; - print ''.$langs->trans("ManufacturingOrder"); + print ''.$langs->trans("ManufacturingOrder"); if (!empty($showImportButton) && $conf->global->MAIN_ENABLE_IMPORT_LINKED_OBJECT_LINES) { $url = DOL_URL_ROOT.'/mrp/mo_card.php?id='.$objectlink->id; print ' '; } print ''; - print ''.$objectlink->getNomUrl(1).''; + print ''.$objectlink->getNomUrl(1).''; print ''.$objectlink->ref_client.''; print ''.dol_print_date($objectlink->date_start_planned, 'day').''; print '-'; diff --git a/htdocs/reception/tpl/linkedobjectblock.tpl.php b/htdocs/reception/tpl/linkedobjectblock.tpl.php index 009534b91b5..341e30e3784 100644 --- a/htdocs/reception/tpl/linkedobjectblock.tpl.php +++ b/htdocs/reception/tpl/linkedobjectblock.tpl.php @@ -50,12 +50,12 @@ foreach ($linkedObjectBlock as $key => $objectlink) { } ?> - trans("Reception"); ?> + trans("Reception"); ?> global->MAIN_ENABLE_IMPORT_LINKED_OBJECT_LINES) { print ' - getNomUrl(1); ?> + getNomUrl(1); ?> ref_supplier); ?> date_delivery, 'day'); ?> $objectlink) { } ?> - trans("Ticket"); ?> + trans("Ticket"); ?> global->MAIN_ENABLE_IMPORT_LINKED_OBJECT_LINES) { print ' - getNomUrl(1); ?> + getNomUrl(1); ?> ref_client; ?> datec, 'day'); ?>