Skip to Content
Menu
This question has been flagged
2 Replies
1029 Views

hello 

i want to change the behaivior of the function in Pos 

inside 

odoo/addons/point_of_sale/static/src/js/Misc/AbstractReceiptScreen.js

the function logic is 

async _printWeb() {
try {
window.print();
return true;
} catch (_err) {
await this.showPopup('ErrorPopup', {
title: this.env._t('Printing is not supported on some browsers'),
body: this.env._t(
'Printing is not supported on some browsers due to no default printing protocol ' +
'is available. It is possible to print your tickets by making use of an IoT Box.'
),
});
return false;
}
}

💡

i want to change the part of window.print();


if this is can be done using some sort of inheritance or anything 
thank you  in advance

Avatar
Discard
Author Best Answer

i have used this method but still can't manage to make it work 

odoo.define('custom_module.CustomReceiptScreen', function (require) {
'use strict';
const ReceiptScreen = require('point_of_sale.ReceiptScreen');
const Registries = require('point_of_sale.Registries');
const CustomReceiptScreen = (ReceiptScreen) => {
class CustomReceiptScreen extends ReceiptScreen {
async printReceipt() {
alert("yaw rani hna")
// Add your custom printing logic here
console.log('Custom printReceipt logic');

// Call the original method if needed
const currentOrder = this.currentOrder;
const isPrinted = await this._printReceipt();




if (isPrinted) {
currentOrder._printed = true;
}

}));
if (isPrinted) {
currentOrder._printed = true;
}
// Additional custom logic
// ...
}
}
CustomReceiptScreen.template = 'ReceiptScreen';
return CustomReceiptScreen;
};

Registries.Component.addByExtending(CustomReceiptScreen, ReceiptScreen);

return CustomReceiptScreen;
});

my problem is that i'ts not called even though that i have added to  "assets" :
'point_of_sale'[]

Avatar
Discard
Best Answer

Hi,

const customScreen = (AbstractReceiptScreen) => {

        class customScreen extends AbstractReceiptScreen {

             /**

                * @Override AbstractReceiptScreen

             */

            setup() {

                super.setup();

            }

            confirm() {

                //Returns to the product screen when we click confirm

                this.showScreen('ProductScreen');

            }

            async _printWeb() {

                 // Your custom print logic here            }

        }

        customScreen.template = 'LocationSummaryReceiptScreen';

        return customScreen;

    };

    Registries.Component.addByExtending(customScreen, AbstractReceiptScreen);

    return customScreen;


Hope it helps

Avatar
Discard
Related Posts Replies Views Activity
1
Feb 22
4747
0
Apr 25
697
0
Aug 20
2431
1
Dec 23
1053
0
Nov 23
38