You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
31 lines
1.3 KiB
31 lines
1.3 KiB
odoo.define('vehicle_subscription.subscription_cancellation', function (require) {
|
|
"use strict";
|
|
var publicWidget = require('web.public.widget');
|
|
const ajax = require('web.ajax');
|
|
publicWidget.registry.Cancellation = publicWidget.Widget.extend({
|
|
selector: '.cancel_sub',
|
|
start: function() {
|
|
this._super.apply(this, arguments);
|
|
this._onChangeCustomer(); // Call the function initially
|
|
},
|
|
//On the onchange function customer is passed to controller
|
|
_onChangeCustomer: async function(ev){
|
|
var self=this;
|
|
var customer_id = this.$('input[name="customer"]')[0].value
|
|
await ajax.jsonRpc('/online/choose/vehicle', "call", {
|
|
'customer_id': customer_id,
|
|
})
|
|
.then(function(result) {
|
|
const select = self.$el.find('#vehicle_cancellation')[0];
|
|
const options = Array.from(select.options);
|
|
options.forEach((option) => {
|
|
option.remove();
|
|
});
|
|
result.forEach((item) => {
|
|
let newOption = new Option(item[1], item[0]);
|
|
select.add(newOption, undefined);
|
|
});
|
|
});
|
|
}
|
|
})
|
|
})
|
|
|