Skip to content

Commit

Permalink
made getVATRates synchronous to avoid concurrency problems
Browse files Browse the repository at this point in the history
  • Loading branch information
csalvador committed Nov 28, 2013
1 parent cd5f2b8 commit 2da88a2
Showing 1 changed file with 18 additions and 15 deletions.
33 changes: 18 additions & 15 deletions htdocs/core/tpl/objectline_add.tpl.php
Expand Up @@ -242,7 +242,6 @@
$('#service_duration_area').hide();

$('#idprod').change(function() {

if ($(this).val() > 0) {

// Update vat rate combobox
Expand All @@ -260,11 +259,11 @@ function(data) {
if (typeof data != 'undefined') {
$('#product_ref').val(data.ref);
$('#product_label').val(data.label);
$('#origin_tva_tx_cache').val(data.tva_tx);
$('#price_base_type').val(data.pricebasetype).trigger('change');
$('#price_ht').val(data.price_ht).trigger('change');
$('#origin_price_ht_cache').val(data.price_ht);
//$('#origin_price_ttc_cache').val(data.price_ttc);
$('#origin_tva_tx_cache').val(data.tva_tx);
$('#select_type').val(data.type).attr('disabled','disabled').trigger('change');
//$('#price_base_type_area').show();
$('#qty').val(data.qty);
Expand All @@ -283,9 +282,6 @@ function(data) {

$('#price_ttc').val('');

// Restore vat rate combobox
getVATRates('getSellerVATRates', 'tva_tx');

// For compatibility with combobox
<?php if (empty($conf->global->PRODUIT_USE_SEARCH_TO_SELECT)) { ?>
$('#select_type').val('').removeAttr('disabled').trigger('change');
Expand Down Expand Up @@ -466,16 +462,23 @@ function update_price(input, output) {

function getVATRates(action, htmlname, idprod) {
var productid = (idprod?idprod:0);
$.post('<?php echo DOL_URL_ROOT; ?>/core/ajax/vatrates.php', {
'action': action,
'id': <?php echo $buyer->id; ?>,
'productid': productid,
'htmlname': htmlname },
function(data) {
if (typeof data != 'undefined' && data.error == null) {
$("#" + htmlname).html(data.value).trigger('change');
}
}, 'json');
$.ajax({
type: "POST",
url: '<?php echo DOL_URL_ROOT;?>/core/ajax/vatrates.php',
data: {
'action': action,
'id': <?php echo $buyer->id; ?>,
'productid': productid,
'htmlname': htmlname
},
success: function(data){
if (typeof data != 'undefined' && data.error == null) {
$("#" + htmlname).html(data.value).trigger('change');
}
},
dataType: "json",
async: false
});
}

// Check if decription is not empty for free line
Expand Down

0 comments on commit 2da88a2

Please sign in to comment.