Simple enough:
$(function(){
const lists = $("#branch, #warehouse");
lists.change(function(){
const value = this.value;
lists.not(this).prop("disabled", value !== "");
});
const nonEmpty = lists.filter(function() { return this.value !== ""; }).eq(0);
if (nonEmpty.length) {
lists.not(nonEmpty).prop("disabled", true);
}
});
If you want to change how you select the lists, then change the selectors in the
const lists = ...
line.