diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php index 6ea03d8bd23..1e2eb0bd8bb 100644 --- a/htdocs/compta/facture/card.php +++ b/htdocs/compta/facture/card.php @@ -3730,8 +3730,10 @@ if ($action == 'create') { print ''."\n"; print ''."\n"; print ''."\n"; - print ''; - print ''; + // The lines below override the parameters set by GET or POST for origin value and also be present in $origin and $originid variables (it make creation of invoice originating from an external module object impossible because for get an external module class we also need to know the name of the module in addition of the name of the element). + // This input fields already printed above at the
begin. + //print ''; + //print ''; switch (get_class($objectsrc)) { case 'Propal': diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index ab258d736ff..c4564ddcd6d 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -3708,10 +3708,23 @@ abstract class CommonObject } } + // Elements of the core modules which have `$module` property but may to which we don't want to prefix module part to the element name for finding the linked object in llx_element_element. + // It's because an entry for this element may be exist in llx_element_element before this modification (version <=14.2) and ave named only with their element name in fk_source or fk_target. + $coremodule = array('knowledgemanagement', 'partnership', 'workstation', 'ticket', 'recruitment', 'eventorganization'); + $sourceid = (!empty($sourceid) ? $sourceid : $this->id); $targetid = (!empty($targetid) ? $targetid : $this->id); - $sourcetype = (!empty($sourcetype) ? $sourcetype : $this->element); - $targettype = (!empty($targettype) ? $targettype : $this->element); + // For module whit + if (empty($sourcetype)) { + // If empty $sourcetype and no core module, add module part for searching element in llx_element_element (needed for external module). + if (!empty($this->module) && ! in_array($this->module, $coremodule)) $sourcetype = $this->module.'_'.$this->element; + else $sourcetype = $this->element; + } + if (empty($targettype)) { + // If empty $targettype and no core module, add module part for searching element in llx_element_element (needed for external module). + if (!empty($this->module) && ! in_array($this->module, $coremodule)) $targettype = $this->module.'_'.$this->element; + else $targettype = $this->element; + } /*if (empty($sourceid) && empty($targetid)) {