From e89dd3bfaab069bdb155dbdfed0ff65b089f5b87 Mon Sep 17 00:00:00 2001 From: Finta <56076718+ionutfinta@users.noreply.github.com> Date: Mon, 12 Feb 2024 05:38:51 +0100 Subject: [PATCH] NEW: Automatically fill matching extra fields of object on line creation. (#27240) * Update objectline_create.tpl.php - Auto-fill matching extra fields This change allows to automatically fill the matching extra fields in a form when adding an object (product/service). * Change spaces to tabs. --- htdocs/core/tpl/objectline_create.tpl.php | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/htdocs/core/tpl/objectline_create.tpl.php b/htdocs/core/tpl/objectline_create.tpl.php index 3547747a1f4..eb1b1dddc53 100644 --- a/htdocs/core/tpl/objectline_create.tpl.php +++ b/htdocs/core/tpl/objectline_create.tpl.php @@ -833,6 +833,17 @@ if (!empty($usemargins) && $user->hasRight('margins', 'creer')) { jQuery("#price_ht").val(data.price_ht); } + // Set values for any fields in the form options_SOMETHING + for (var key in data.array_options) { + if (data.array_options.hasOwnProperty(key)) { + var field = jQuery("#" + key); + if(field.length > 0){ + console.log("objectline_create.tpl set content of options_" + key); + field.val(data.array_options[key]); + } + } + } + var tva_tx = data.tva_tx; var default_vat_code = data.default_vat_code;