Pricing Rule not changed sharp after changing customer if document save quickly

I’ve apply pricing rule on a customer while loading items after selecting Customer (which have Pricing Rule assign) and adding items on Sales Order Pricing Rule appied but before saving if change the customer to another sharp and save the Sales Order, Pricing Rule is applied to other customer how to fix it?

While changing the customer on the sales order form, the item rates do not update sharply according to the pricing rule of the selected customer. However, while updating the rates the user can save the document with the previous customer’s pricing rule and rate.
To update item rates for new customers, we applied script to disable Save Button for a few seconds. and its work

frappe.ui.form.on('Sales Order', {
    onload: function(frm) {
        // Variable to track if Customer field has been changed
        frm.custom_script_customer_changed = false;

        // Function to disable the Save button for 30 seconds
        function disableSaveButton() {
            frm.disable_save();
            setTimeout(function() {
                frm.enable_save();
            }, 30000); // 30 seconds
        }

        // When the Customer field is changed, set the flag and call the function to disable Save button
        frm.doc.on('customer', function() {
            frm.custom_script_customer_changed = true;
            disableSaveButton();
        });

        // When the form is saved successfully, reset the flag to allow normal Save behavior
        frm.saved = function() {
            frm.custom_script_customer_changed = false;
        };
    },

    // Additional hooks can be added here if needed...
});