refactor: update service references and remove unused jsonrpc import for Odoo 19 compatibility

This commit is contained in:
Suherdy Yacob 2026-05-06 11:12:58 +07:00
parent e3c152c102
commit 9b4855b396

View File

@ -3,7 +3,8 @@
import { patch } from "@web/core/utils/patch"; import { patch } from "@web/core/utils/patch";
import { NumberPopup } from "@point_of_sale/app/components/popups/number_popup/number_popup"; import { NumberPopup } from "@point_of_sale/app/components/popups/number_popup/number_popup";
import { TicketScreen } from "@point_of_sale/app/screens/ticket_screen/ticket_screen"; import { TicketScreen } from "@point_of_sale/app/screens/ticket_screen/ticket_screen";
import { jsonrpc } from "@web/core/network/rpc_service"; // jsonrpc removed - not used and causing dependency error in Odoo 19
import { AlertDialog as ErrorPopup } from "@web/core/confirmation_dialog/confirmation_dialog"; import { AlertDialog as ErrorPopup } from "@web/core/confirmation_dialog/confirmation_dialog";
import { _t } from "@web/core/l10n/translation"; import { _t } from "@web/core/l10n/translation";
//Refund password validation and popup //Refund password validation and popup
@ -12,7 +13,7 @@ patch(TicketScreen.prototype, {
const order = this.getSelectedOrder(); const order = this.getSelectedOrder();
// Check if order is posted // Check if order is posted
if (order.state == 'done') { if (order.state == 'done') {
this.popup.add(ErrorPopup,{ this.env.services.popup.add(ErrorPopup,{
body : _t('Refund Not Allowed, This order has already been posted and cannot be refunded.'), body : _t('Refund Not Allowed, This order has already been posted and cannot be refunded.'),
}); });
return; return;
@ -20,29 +21,29 @@ patch(TicketScreen.prototype, {
var refund=""; var refund="";
var session_refund= false; var session_refund= false;
var data = await this.orm.call("pos.config", "fetch_global_refund_security", []) var data = await this.env.services.orm.call("pos.config", "fetch_global_refund_security", [])
refund = data; refund = data;
if (!refund){ if (!refund){
session_refund = this.pos.config.refund_security; session_refund = this.pos.config.refund_security;
} }
if(refund){ if(refund){
const { confirmed, payload } = await this.popup.add(NumberPopup, { isPassword: true }) const { confirmed, payload } = await this.env.services.popup.add(NumberPopup, { isPassword: true })
if(refund == payload){ if(refund == payload){
super.onDoRefund(...arguments); super.onDoRefund(...arguments);
} }
else{ else{
this.popup.add(ErrorPopup,{ this.env.services.popup.add(ErrorPopup,{
body : _t('Invalid Password, Enter your global password'), body : _t('Invalid Password, Enter your global password'),
}); });
} }
} }
else if(session_refund){ else if(session_refund){
const { confirmed, payload } = await this.popup.add(NumberPopup, { isPassword: true }) const { confirmed, payload } = await this.env.services.popup.add(NumberPopup, { isPassword: true })
if(session_refund == payload){ if(session_refund == payload){
super.onDoRefund(...arguments); super.onDoRefund(...arguments);
} }
else{ else{
this.popup.add(ErrorPopup,{ this.env.services.popup.add(ErrorPopup,{
body : _t('Incorrect Password'), body : _t('Incorrect Password'),
}); });
} }