Line 542:
Line 542:
// Filling the $object with customfields (you can then access customfields by doing $object->customfields->cf_yourfield)
// Filling the $object with customfields (you can then access customfields by doing $object->customfields->cf_yourfield)
$linecf = new stdClass();
$linecf = new stdClass();
−
$linecf->id = $line->rowid;
+
$linecf->id = (!empty($line->id))?$line->id:$line->rowid;
−
$linecf->table_element = 'facturedet'; // you can use $this->table_element_line here instead of 'facturedet' if you want this feature to work for every module supported by CustomFields
+
$linecf->table_element = $object->table_element_line; // you can use $object->table_element_line here instead of 'facturedet' if you want this feature to work for every module supported by CustomFields
$customfields = customfields_fill_object($linecf);
$customfields = customfields_fill_object($linecf);
Line 549:
Line 549:
// Applying a multiplying/dividing coefficient to an HT price will give a mathematically correct TTC price since the taxes are also a multiplier
// Applying a multiplying/dividing coefficient to an HT price will give a mathematically correct TTC price since the taxes are also a multiplier
// However, if you want to apply other mathematical operations (like addition or substaction), you should use the total price with $line->total_ttc
// However, if you want to apply other mathematical operations (like addition or substaction), you should use the total price with $line->total_ttc
−
echo price($line->total_ht * $linecf->customfields->cf_coefficient);
+
if (isset($linecf->customfields->cf_coefficient)) {
+
echo price($line->total_ht * $linecf->customfields->cf_coefficient);
+
} else {
+
echo price($line->total_ht);
+
}
?>
?>
</source>
</source>