Zum Inhalt springen
Menü
Sie müssen registriert sein, um mit der Community zu interagieren.
Diese Frage wurde gekennzeichnet
2 Antworten
1648 Ansichten

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
Verwerfen
Autor Beste Antwort

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
Verwerfen
Beste Antwort

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
Verwerfen
Verknüpfte Beiträge Antworten Ansichten Aktivität
1
Feb. 22
5265
0
Apr. 25
1365
0
Aug. 20
2431
1
Dez. 23
1686
0
Nov. 23
38