diff --git a/product_warranty_management_odoo/static/src/js/website_registration.js b/product_warranty_management_odoo/static/src/js/website_registration.js
index e6fa92b44..cd2e5d0e9 100644
--- a/product_warranty_management_odoo/static/src/js/website_registration.js
+++ b/product_warranty_management_odoo/static/src/js/website_registration.js
@@ -1,123 +1,127 @@
-/**@odoo-module*/
+/** @odoo-module **/
+
import publicWidget from "@web/legacy/js/public/public_widget";
publicWidget.registry.WarrantyClaim = publicWidget.Widget.extend({
-//init function to bind rpc
-init(){
- this.rpc = this.bindService("rpc");
-},
selector: '.container',
+
events: {
- 'click #customer_id': '_onClickCustomer',
'change #customer_id': '_onClickCustomer',
- 'click #sale_order_id': '_onClickSaleOrder',
'change #sale_order_id': '_onClickSaleOrder',
- 'submit #form_submit': '_onSubmit'
+ 'submit #form_submit': '_onSubmit',
+ },
+
+ willStart: function () {
+ const def = this._super.apply(this, arguments);
+ this.rpc = this.bindService("rpc");
+ return def;
},
_onClickCustomer: function (ev) {
- // To show the sale order of the selected customer only
ev.preventDefault();
- var selectedCustomerId = this.$('#customer_id').val();
- var $saleOrderDropdown = this.$('#sale_order_id');
- var $productDropdown = this.$('#products_id');
+ const selectedCustomerId = this.$('#customer_id').val();
+ const $saleOrderDropdown = this.$('#sale_order_id');
+ const $productDropdown = this.$('#products_id');
+
$saleOrderDropdown.empty().append('').prop('disabled', true);
$productDropdown.empty().append('').prop('disabled', true);
+
if (selectedCustomerId) {
this.rpc('/partner/sale_order', {
- 'partner_id': parseInt(selectedCustomerId)
- }).then(function (result) {
- if (result.length > 0) {
- $saleOrderDropdown.prop('disabled', false);
- $.each(result, function (i, saleOrder) {
- $saleOrderDropdown.append($('').prop('disabled', true);
- var self = this
+
if (selectedSaleOrderId) {
- this.rpc('/partner/sale_order_line', {
- 'order_id': parseInt(selectedSaleOrderId)
- }).then(function (result) {
- var $productDropdown = self.$('#products_id');
- $productDropdown.prop('disabled', false);
- $productDropdown.empty();
- $.each(result, function (i, saleOrderLine) {
- $productDropdown.append($('