Fix creataing invoice originating for custom module
This fix the invoice create form when we provide `origin` element in url. The actual create form overide the value for origin field with `$objectsrc->element`. This make creation of invoice originating from a custom module module impossible because we need the module part to instantiate the class for the custom module object. This also modify Common Object::fetch Object Linked() to append the module part for `$sourcetype` and `$targettype` if it not set and object have module property and it not in core module.
This commit is contained in:
parent
b559dc9053
commit
6c82b1d0e1
@ -3730,8 +3730,10 @@ if ($action == 'create') {
|
||||
print '<input type="hidden" name="amount" value="'.$objectsrc->total_ht.'">'."\n";
|
||||
print '<input type="hidden" name="total" value="'.$objectsrc->total_ttc.'">'."\n";
|
||||
print '<input type="hidden" name="tva" value="'.$objectsrc->total_tva.'">'."\n";
|
||||
print '<input type="hidden" name="origin" value="'.$objectsrc->element.'">';
|
||||
print '<input type="hidden" name="originid" value="'.$objectsrc->id.'">';
|
||||
// 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 <form> begin.
|
||||
//print '<input type="hidden" name="origin" value="'.$objectsrc->element.'">';
|
||||
//print '<input type="hidden" name="originid" value="'.$objectsrc->id.'">';
|
||||
|
||||
switch (get_class($objectsrc)) {
|
||||
case 'Propal':
|
||||
|
||||
@ -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))
|
||||
{
|
||||
|
||||
Loading…
Reference in New Issue
Block a user