如何从销售订单打印 POS 收据?
How to print a POS receipt from Sale Order?
我需要打印具有相同产品数量等的销售订单的 POS 收据
在销售订单中,我创建了一个按钮 "Print POS receIpt"。使用此按钮,我想触发一种方法,该方法打印出带有销售订单行的收据。
所以我需要找到创建 POS 收据并将销售订单行值传递给它的方法。
那么POS机打印收据的方法是什么,如何触发呢?它在 models.js
中吗?
在那些 Odoo 版本中,在 POS 中打印的收据是 JavaScript 制作的屏幕截图(实际上只是收据 div)。但是您不能在销售订单视图中使用此方法。
但是,还有另一种方法可以使用普通 Qweb 报告将票证打印成 PDF。如果单击 POS 菜单,您将在左边距找到 "Orders" 菜单选项。您将在表单和列表视图的 "Print" 菜单下看到打印选项。
如果您转到 point_of_sale
模块,您将找到用 Qweb 语言编写的 report_receipt.xml
文件。您可以自定义它以使其与 sale.order
模型一起使用。但是考虑到 paperformat 应该是 point_of_sale.paperformat_posreceipt
,你会在这些代码的底部找到 paperformat 分配:
<template id="report_receipt">
<t t-call="report.html_container">
<t t-foreach="docs" t-as="o">
<div class="page">
<div class="row">
<div class="col-xs-12 text-center">
<h2 t-esc="o.user_id.company_id.name"/>
<div t-field="o.partner_id"
t-field-options='{"widget": "contact", "fields": ["address", "name", "phone", "fax"], "no_marker": true}'/>
User: <span t-field="o.user_id"/><br/>
Date: <span t-field="o.date_order"/><br/>
</div>
</div>
<div class="row">
</div>
<table class="table table-condensed">
<thead>
<tr>
<th>Description</th>
<th class="text-right">Quantity</th>
<th class="text-right">Price</th>
</tr>
</thead>
<tbody>
<tr t-foreach="o.lines" t-as="line">
<td><span t-field="line.product_id"/></td>
<td class="text-right">
<t t-if="o.state != 'cancel' and o.statement_ids">
<span t-field="line.qty"/>
</t>
</td>
<td class="text-right">
<t t-if="o.state != 'cancel' and o.statement_ids">
<span t-esc="formatLang(net(line.id), currency_obj=res_company.currency_id)"/>
</t>
<t t-if="line.discount != 0.0">
<span t-esc="line.discount"/>%
</t>
</td>
</tr>
</tbody>
</table>
<div class="row">
<div class="col-xs-12 pull-right">
<table class="table table-condensed">
<tr class="border-black">
<td><strong>Taxes</strong></td>
<td class="text-right">
<strong t-esc="formatLang(o.amount_tax, currency_obj=res_company.currency_id)"/>
</td>
</tr>
<tr>
<td><strong>Total</strong></td>
<td class="text-right">
<strong t-esc="formatLang(o.amount_total, currency_obj=res_company.currency_id)"/>
</td>
</tr>
</table>
</div>
</div>
<table class="table table-condensed">
<thead>
<tr>
<th>Payment Mode</th>
<th>Amount</th>
</tr>
</thead>
<tbody>
<tr t-foreach="get_journal_amt(o)" t-as="d">
<td>
<span t-esc="d['name']"/>
</td>
<td>
<span t-esc="formatLang(d['amt'], currency_obj=res_company.currency_id)"/>
</td>
</tr>
</tbody>
</table>
</div>
</t>
</t>
</template>
<report
id="action_report_pos_receipt"
string="Receipt"
model="pos.order"
report_type="qweb-pdf"
name="point_of_sale.report_receipt"
file="point_of_sale.report_receipt"
/>
<record id="action_report_pos_receipt" model="ir.actions.report.xml">
<field name="paperformat_id" ref="point_of_sale.paperformat_posreceipt"/>
</record>
我需要打印具有相同产品数量等的销售订单的 POS 收据
在销售订单中,我创建了一个按钮 "Print POS receIpt"。使用此按钮,我想触发一种方法,该方法打印出带有销售订单行的收据。
所以我需要找到创建 POS 收据并将销售订单行值传递给它的方法。
那么POS机打印收据的方法是什么,如何触发呢?它在 models.js
中吗?
在那些 Odoo 版本中,在 POS 中打印的收据是 JavaScript 制作的屏幕截图(实际上只是收据 div)。但是您不能在销售订单视图中使用此方法。
但是,还有另一种方法可以使用普通 Qweb 报告将票证打印成 PDF。如果单击 POS 菜单,您将在左边距找到 "Orders" 菜单选项。您将在表单和列表视图的 "Print" 菜单下看到打印选项。
如果您转到 point_of_sale
模块,您将找到用 Qweb 语言编写的 report_receipt.xml
文件。您可以自定义它以使其与 sale.order
模型一起使用。但是考虑到 paperformat 应该是 point_of_sale.paperformat_posreceipt
,你会在这些代码的底部找到 paperformat 分配:
<template id="report_receipt">
<t t-call="report.html_container">
<t t-foreach="docs" t-as="o">
<div class="page">
<div class="row">
<div class="col-xs-12 text-center">
<h2 t-esc="o.user_id.company_id.name"/>
<div t-field="o.partner_id"
t-field-options='{"widget": "contact", "fields": ["address", "name", "phone", "fax"], "no_marker": true}'/>
User: <span t-field="o.user_id"/><br/>
Date: <span t-field="o.date_order"/><br/>
</div>
</div>
<div class="row">
</div>
<table class="table table-condensed">
<thead>
<tr>
<th>Description</th>
<th class="text-right">Quantity</th>
<th class="text-right">Price</th>
</tr>
</thead>
<tbody>
<tr t-foreach="o.lines" t-as="line">
<td><span t-field="line.product_id"/></td>
<td class="text-right">
<t t-if="o.state != 'cancel' and o.statement_ids">
<span t-field="line.qty"/>
</t>
</td>
<td class="text-right">
<t t-if="o.state != 'cancel' and o.statement_ids">
<span t-esc="formatLang(net(line.id), currency_obj=res_company.currency_id)"/>
</t>
<t t-if="line.discount != 0.0">
<span t-esc="line.discount"/>%
</t>
</td>
</tr>
</tbody>
</table>
<div class="row">
<div class="col-xs-12 pull-right">
<table class="table table-condensed">
<tr class="border-black">
<td><strong>Taxes</strong></td>
<td class="text-right">
<strong t-esc="formatLang(o.amount_tax, currency_obj=res_company.currency_id)"/>
</td>
</tr>
<tr>
<td><strong>Total</strong></td>
<td class="text-right">
<strong t-esc="formatLang(o.amount_total, currency_obj=res_company.currency_id)"/>
</td>
</tr>
</table>
</div>
</div>
<table class="table table-condensed">
<thead>
<tr>
<th>Payment Mode</th>
<th>Amount</th>
</tr>
</thead>
<tbody>
<tr t-foreach="get_journal_amt(o)" t-as="d">
<td>
<span t-esc="d['name']"/>
</td>
<td>
<span t-esc="formatLang(d['amt'], currency_obj=res_company.currency_id)"/>
</td>
</tr>
</tbody>
</table>
</div>
</t>
</t>
</template>
<report
id="action_report_pos_receipt"
string="Receipt"
model="pos.order"
report_type="qweb-pdf"
name="point_of_sale.report_receipt"
file="point_of_sale.report_receipt"
/>
<record id="action_report_pos_receipt" model="ir.actions.report.xml">
<field name="paperformat_id" ref="point_of_sale.paperformat_posreceipt"/>
</record>