From 7146a8319bacaf3d8913b0aeeef55c833eb27e7f Mon Sep 17 00:00:00 2001
From: Laurent Destailleur <eldy@destailleur.fr>
Date: Wed, 30 Mar 2016 16:26:34 +0200
Subject: [PATCH] FIX Each time we edit a line, we loose the unit price.

---
 htdocs/core/tpl/objectline_edit.tpl.php | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/htdocs/core/tpl/objectline_edit.tpl.php b/htdocs/core/tpl/objectline_edit.tpl.php
index 7c75e0ae49b..7723123bc0e 100644
--- a/htdocs/core/tpl/objectline_edit.tpl.php
+++ b/htdocs/core/tpl/objectline_edit.tpl.php
@@ -252,6 +252,10 @@ if (! empty($conf->margin->enabled))
 			jQuery("input[name='np_marginRate']:first").val('');
 			jQuery("input[name='np_markRate']:first").val('');
 		});
+		jQuery("#qty").keyup(function() {
+			jQuery("input[name='np_marginRate']:first").val('');
+			jQuery("input[name='np_markRate']:first").val('');
+		});
 		jQuery("#remise_percent").keyup(function() {
 			jQuery("input[name='np_marginRate']:first").val('');
 			jQuery("input[name='np_markRate']:first").val('');
@@ -300,7 +304,7 @@ if (! empty($conf->margin->enabled))
 
 		/* Add rules to reset price_ht from margin info */
 		<?php
-		if (! empty($conf->global->DISPLAY_MARGIN_RATES))
+		if (! empty($conf->global->DISPLAY_MARGIN_RATES) && !empty($conf->global->MARGIN_RESET_HT_FROM_MARGIN_FIELD))
 		{
 		?>
 			$('#savelinebutton').click(function (e) {
@@ -312,7 +316,7 @@ if (! empty($conf->margin->enabled))
 			});*/
 		<?php
 		}
-		if (! empty($conf->global->DISPLAY_MARK_RATES))
+		if (! empty($conf->global->DISPLAY_MARK_RATES) && !empty($conf->global->MARGIN_RESET_HT_FROM_MARGIN_FIELD))
 		{
 		?>
 			$('#savelinebutton').click(function (e) {
-- 
GitLab