<commit_before>odoo.define('point_of_sale.Printer', function (require) {
"use strict";

var Session = require('web.Session');
var core = require('web.core');
var _t = core._t;

var PrinterMixin = {
    init: function () {
        this.receipt_queue = [];
    },

    /**
     * Add the receipt to the queue of receipts to be printed and process it.
     * @param {String} receipt: The receipt to be printed, in HTML
     */
    print_receipt: function (receipt) {
        var self = this;
        if (receipt) {
            this.receipt_queue.push(receipt);
        }
        function process_next_job() {
            if (self.receipt_queue.length > 0) {
                var r = self.receipt_queue.shift();
                self.htmlToImg(r)
                    .then(self.send_printing_job.bind(self))
                    .then(self._onIoTActionResult.bind(self))
                    .then(process_next_job)
                    .guardedCatch(self._onIoTActionFail.bind(self));
            }
        }
        process_next_job();
    },

    /**
     * Generate a jpeg image from a canvas
     * @param {DOMElement} canvas 
     */
    process_canvas: function (canvas) {
        return canvas.toDataURL('image/jpeg').replace('data:image/jpeg;base64,','');
    },

    /**
     * Renders the html as an image to print it
     * @param {String} receipt: The receipt to be printed, in HTML
     */
    htmlToImg: function (receipt) {
        var self = this;
        $('.pos-receipts').html(receipt);
        $('.pos-receipt').addClass('pos-receipt-print');
        var promise = new Promise(function (resolve, reject) {
            html2canvas($('.pos-receipt')[0], {
                ignoreElements: function (node) {
                    // By default, html2canvas copies the whole DOM even if we just capture a part
                    // of it. When copying the list of products, it gets all of the product from the
                    // backend. We ignore the content of <div class="pos"> to speed things up.
                    if (node.className == "pos") {
                        return true;
                    }
                    return false;
                }
            }).then(function (canvas) {<commit_msg>[FIX] point_of_sale: Receipt color after print<commit_after>odoo.define('point_of_sale.Printer', function (require) {
"use strict";

var Session = require('web.Session');
var core = require('web.core');
var _t = core._t;

var PrinterMixin = {
    init: function () {
        this.receipt_queue = [];
    },

    /**
     * Add the receipt to the queue of receipts to be printed and process it.
     * @param {String} receipt: The receipt to be printed, in HTML
     */
    print_receipt: function (receipt) {
        var self = this;
        if (receipt) {
            this.receipt_queue.push(receipt);
        }
        function process_next_job() {
            if (self.receipt_queue.length > 0) {
                var r = self.receipt_queue.shift();
                self.htmlToImg(r)
                    .then(self.send_printing_job.bind(self))
                    .then(self._onIoTActionResult.bind(self))
                    .then(process_next_job)
                    .guardedCatch(self._onIoTActionFail.bind(self));
            }
        }
        process_next_job();
    },

    /**
     * Generate a jpeg image from a canvas
     * @param {DOMElement} canvas 
     */
    process_canvas: function (canvas) {
        return canvas.toDataURL('image/jpeg').replace('data:image/jpeg;base64,','');
    },

    /**
     * Renders the html as an image to print it
     * @param {String} receipt: The receipt to be printed, in HTML
     */
    htmlToImg: function (receipt) {
        var self = this;
        $('.pos-receipts').html(receipt);
        $('.pos-receipts>.pos-receipt').addClass('pos-receipt-print');
        var promise = new Promise(function (resolve, reject) {
            html2canvas($('.pos-receipt-print')[0], {
                ignoreElements: function (node) {
                    // By default, html2canvas copies the whole DOM even if we just capture a part
                    // of it. When copying the list of products, it gets all of the product from the
                    // backend. We ignore the content of <div class="pos"> to speed things up.
                    if (node.className == "pos") {
                        return true;
                    }
                    return false;
                }
            }).then(function (canvas) {
{'fraction_non_alphanumeric': 0.1166407465007776, 'fraction_numerical': 0.0026660742057320595, 'mean_word_length': 1.7704615384615385, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 8, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6430722', 'n_tokens_mistral': 1335, 'n_tokens_neox': 1236, 'n_words': 343}