Odoo Help

1

0
1 Answer
2
Niraj Pajwani
1/28/19, 8:17 AM
var _onCarrierUpdateAnswer = function(result) {
    var $amount_delivery = $('#order_delivery span.oe_currency_value');
    var $amount_untaxed = $('#order_total_untaxed span.oe_currency_value');
    var $amount_tax = $('#order_total_taxes span.oe_currency_value');
    var $amount_total = $('#order_total span.oe_currency_value');
    var $carrier_badge = $('#delivery_carrier input[name="delivery_type"][value=' + result.carrier_id + '] ~ .badge.hidden');
    var $compute_badge = $('#delivery_carrier input[name="delivery_type"][value=' + result.carrier_id + '] ~ .o_delivery_compute');
    if (result.status === true) {
        $amount_delivery.text(result.new_amount_delivery);
        $amount_untaxed.text(result.new_amount_untaxed);
        $amount_tax.text(result.new_amount_tax);
        $amount_total.text(result.new_amount_total);
        $carrier_badge.children('span').text(result.new_amount_delivery);
        $carrier_badge.removeClass('hidden');
        $compute_badge.addClass('hidden');
        // your custom code
        $pay_button.prop('disabled', true);
    }
    else {
        console.error(result.error_message);
        $compute_badge.text(result.error_message);
    }
};

var _onCarrierClick = function(ev) {
    $pay_button.prop('disabled', true);
    var carrier_id = $(ev.currentTarget).val();
    var values = {'carrier_id': carrier_id};
    ajax.jsonRpc('/shop/update_carrier', 'call', values)
      .then(_onCarrierUpdateAnswer);
};

var $carriers = $("#delivery_carrier input[name='delivery_type']");
$carriers.off('click');
$carriers.click(_onCarrierClick);
1 Comment
Niraj Pajwani
1/28/19, 8:24 AM

We can't directly inherit _onCarrierUpdateAnswer method. We have to bind click even using our custom code and disconnect the current code.

Here the $carriers.off('click'); will disconnect the original base code and $carriers.click(_onCarrierClick); will help us to bind the click event handler and run our custom code with the modification.

Hope this will help you.

Ask a Question
Writer
Keep Informed
1 follower(s)
About This Community

This platform is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.

Register
Odoo Training Center

Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now