콘텐츠로 건너뛰기
메뉴
커뮤니티에 참여하려면 회원 가입을 하시기 바랍니다.
신고된 질문입니다
1 회신
1673 화면

How do I display the order date on the receipts screen at the point of sales on Odoo 17, here is the pos_receipt_extend module

아바타
취소
베스트 답변

Hi,

The provided code is used to customize the Point of Sale module's receipt header to include the order date.


JS:


/** @odoo-module */


import { patch } from "@web/core/utils/patch";

import { Order } from "@point_of_sale/app/store/models";


patch(Order.prototype, {

export_for_printing() {

const result = super.export_for_printing(...arguments);

result.headerData = {

...this.pos.getReceiptHeaderData(),

date_order: this.date_order,

}

return result;

},

})


The code overrides the export_for_printing method of the Order to include the date_order field in the receipt header data.


XML:

<?xml version="1.0" encoding="UTF-8"?>
<templates id="template" xml:space="preserve">
    <t t-name="CustomReceiptHeader.ReceiptHeader"
       t-inherit="point_of_sale.ReceiptHeader" t-inherit-mode="extension">
            <xpath expr="//div[hasclass('cashier')]" position="after">
                <div class="pos-receipt-contact">
                    <t t-esc="this.props.data.date_order"/>
                </div>
            </xpath>
        </t>
</templates>

Inherit the 'point_of_sale.ReceiptHeader' template and add date_order wherever you want using xpath.

The JS and XML files should be included in the manifest file

"assets": {
        "point_of_sale._assets_pos": [
            "path_to_js_file",
            "path_to_xml_file"
        ]
}



Hope it helps

아바타
취소
관련 게시물 답글 화면 활동
2
1월 23
3538
1
5월 18
5028
2
5월 17
3778
4
11월 16
5064
3
5월 16
8749