跳至内容
菜单
此问题已终结
1084 查看

En este codigo js
/** @odoo-module */

import { _t } from "@web/core/l10n/translation";

import { useErrorHandlers } from "@point_of_sale/app/utils/hooks";

import { registry } from "@web/core/registry";

import { KitchenReceipt } from "./KitchenReceipt";

import { useState, Component } from "@odoo/owl";

import { usePos } from "@point_of_sale/app/store/pos_hook";

import { useService } from "@web/core/utils/hooks";


export class PrintKitchenReceiptScreen extends Component {    

static template = "pos_print_kitchen_receipt.PrintKitchenReceiptScreen";    

static components = { KitchenReceipt };    

setup() {        super.setup();        

this.pos = usePos();        

this.hardwareProxy = useService("hardware_proxy");        

this.printer = useService("printer");        

useErrorHandlers();        

this.ui = useState(useService("ui"));    

}

    async printReceipt() {        // Obtener la lista de impresoras de cocina habilitadas        

const kitchenPrinters = await this.hardwareProxy.get_kitchen_printers();   // Verificar si hay impresoras disponibles       

 if (kitchenPrinters.length > 0) {            

const firstPrinter = kitchenPrinters[0]; // Seleccionar la primera impresora

const isPrinted = await this.printer.print(                

firstPrinter, // Usar la primera impresora                {                   

 data: this.pos.get_order().export_for_printing(),                    

formatCurrency: this.env.utils.formatCurrency,                },        

{ webPrintFallback: true }    );} 

else {    console.error("No hay impresoras de cocina habilitadas.");


Y el resultado es el siguiente:


TypeError: this.hardwareProxy.get_kitchen_printers is not a function at PrintKitchenReceiptScreen.printReceipt (http://localhost:8075/web/assets/bc79012/point_of_sale.assets_prod.min.js:15578:69) at Object.mainEventHandler (http://localhost:8075/web/assets/bc79012/point_of_sale.assets_prod.min.js:1567:77) at HTMLButtonElement.listener (http://localhost:8075/web/assets/bc79012/point_of_sale.assets_prod.min.js:742:15)


形象
丢弃
相关帖文 回复 查看 活动
2
6月 25
1529
2
7月 25
2054
5
7月 25
9385
1
3月 25
1502
0
1月 25
1049