diff --git a/pos_auto_invoice_default_partner/static/src/js/Screens/PaymentScreen/PaymentScreen.esm.js b/pos_auto_invoice_default_partner/static/src/js/Screens/PaymentScreen/PaymentScreen.esm.js new file mode 100644 index 0000000000..1b912152ce --- /dev/null +++ b/pos_auto_invoice_default_partner/static/src/js/Screens/PaymentScreen/PaymentScreen.esm.js @@ -0,0 +1,20 @@ +/** @odoo-module **/ + +import PaymentScreen from "point_of_sale.PaymentScreen"; +import Registries from "point_of_sale.Registries"; + +const InvoiceDefaultPartnerPaymentScreen = (OriginalPaymentScreen) => + class extends OriginalPaymentScreen { + async validateOrder() { + const partner = this.currentOrder.get_partner(); + const default_partner_id = this.env.pos.config.default_partner_id; + if (this.currentOrder.is_to_invoice() && !partner && default_partner_id) { + this.currentOrder.set_partner( + this.env.pos.db.get_partner_by_id(default_partner_id[0]) + ); + } + return super.validateOrder(...arguments); + } + }; + +Registries.Component.extend(PaymentScreen, InvoiceDefaultPartnerPaymentScreen); diff --git a/pos_auto_invoice_default_partner/static/src/js/Screens/PaymentScreen/PaymentScreen.js b/pos_auto_invoice_default_partner/static/src/js/Screens/PaymentScreen/PaymentScreen.js deleted file mode 100644 index d27ce1c5d6..0000000000 --- a/pos_auto_invoice_default_partner/static/src/js/Screens/PaymentScreen/PaymentScreen.js +++ /dev/null @@ -1,28 +0,0 @@ -odoo.define("pos_auto_invoice_default_partner.PaymentScreen", function (require) { - "use strict"; - - const PaymentScreen = require("point_of_sale.PaymentScreen"); - const Registries = require("point_of_sale.Registries"); - - // eslint-disable-next-line no-shadow - const InvoiceDefaultPartnerPaymentScreen = (PaymentScreen) => - // eslint-disable-next-line no-shadow - class InvoiceDefaultPartnerPaymentScreen extends PaymentScreen { - async validateOrder() { - const partner = this.currentOrder.get_partner(); - const default_partner_id = this.env.pos.config.default_partner_id; - if ( - this.currentOrder.is_to_invoice() && - !partner && - default_partner_id - ) { - this.currentOrder.set_partner( - this.env.pos.db.get_partner_by_id(default_partner_id[0]) - ); - } - return super.validateOrder(...arguments); - } - }; - - Registries.Component.extend(PaymentScreen, InvoiceDefaultPartnerPaymentScreen); -});