USe fk_product is better than ref

This commit is contained in:
Laurent Destailleur 2018-02-14 21:14:24 +01:00
parent f3ffc7ce8a
commit 78697c1735
2 changed files with 15 additions and 13 deletions

View File

@ -104,8 +104,11 @@ if ($id > 0 || ! empty($ref)) {
$ret = $object->fetch($id, $ref);
if ($ret > 0)
$ret = $object->fetch_thirdparty();
if ($ret < 0)
dol_print_error('', $object->error);
if ($ret <= 0)
{
setEventMessages($object->error, $object->errors, 'errors');
$action = '';
}
}
// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
@ -1711,7 +1714,7 @@ if ($action == 'create')
print '</table>';
}
} else {
} elseif ($object->id > 0) {
/*
* Show object in view mode
*/
@ -1818,7 +1821,6 @@ if ($action == 'create')
$linkback = '<a href="' . DOL_URL_ROOT . '/comm/propal/list.php?restore_lastsearch_values=1' . (! empty($socid) ? '&socid=' . $socid : '') . '">' . $langs->trans("BackToList") . '</a>';
$morehtmlref='<div class="refidno">';
// Ref customer
$morehtmlref.=$form->editfieldkey("RefCustomer", 'ref_client', $object->ref_client, $object, $user->rights->propal->creer, 'string', '', 0, 1);

View File

@ -529,11 +529,11 @@ abstract class CommonDocGenerator
$resarray = $this->fill_substitutionarray_with_extrafields($line,$resarray,$extrafields,$array_key=$array_key,$outputlangs);
// Load product data optional fields to the line -> enables to use "line_options_{extrafield}"
if (isset($line->product_ref))
if (isset($line->fk_product) && $line->fk_product > 0)
{
$product = new Product($this->db);
$result = $product->fetch(null, $line->product_ref);
foreach($product->array_options as $key=>$label)
$tmpproduct = new Product($this->db);
$result = $tmpproduct->fetch($line->fk_product);
foreach($tmpproduct->array_options as $key=>$label)
$resarray["line_".$key] = $label;
}