J'utilise Odoo10, je veux ajouter un tableau de détail des produits dans POS Receip, et également ajouter un autre bouton Imprimer pour imprimer le tableau de détail seulement. J'ai un problème, je ne sais pas comment ajouter un événement à mon bouton. Voici mon module, s'il vous plaît vérifier pour moi.Comment ajouter un bouton personnalisé à un reçu POS dans Odoo 10
Qweb:
<?xml version="1.0" encoding="UTF-8"?>
<templates id="point_of_sale_template" xml:space="preserve">
<t t-extend="PosTicket">
<t t-jquery='.pos-sale-ticket' t-operation='after'>
<div class="pos-sale-ticket-appended" style="clear:both; text-align: left; width: 300px; background-color: white; margin: 20px; padding: 15px; font-size: 14px;padding-bottom: 30px; display: inline-block;font-family: 'Inconsolata'; border: solid 1px rgb(220,220,220); border-radius: 3px; overflow: hidden;">
<div style="background: white; margin: 20px auto;">
<h4>Products Detail</h4>
<div style="display: inline-block">
<table class='receipt-orderlines' style="width: 300px; border">
<colgroup>
<col width='50%' />
<col width='25%' />
<col width='25%' />
</colgroup>
<tr>
<th>Name</th>
<th>SKU</th>
<th>Cost</th>
</tr>
<tr t-foreach="orderlines" t-as="orderline">
<t t-log="orderline.get_product().cost_method" />
<t t-log="orderline.get_product().property_cost_method" />
<td>
<t t-esc="orderline.get_product().display_name"/>
</td>
<td>
<t t-esc="orderline.get_product().default_code"/>
</td>
<td>
<t t-esc="orderline.get_product().standard_price"/>
</td>
</tr>
</table>
<br />
</div>
</div>
</div>
</t>
</t>
<t t-extend="ReceiptScreenWidget">
<t t-jquery='div.receipt-screen.screen > div > div.centered-content.touch-scrollable > div.button.print' t-operation="after">
<div class="button print-detail">
<i class='fa fa-print'></i> Print Detail
</div>
</t>
</t>
</templates>
JS: Je tiens à offrir tout modèle pos et ajouter le champ de standard_price
odoo.define('pos_receipt_extend', function (require) {
"use strict";
var $ = require('jquery');
// Add cost field to product model
var models = require('point_of_sale.models');
models.load_fields('product.product', 'standard_price');
var screens = require('point_of_sale.screens');
});
manifeste .py
# -*- coding: utf-8 -*-
{
"name": "Pos extend Receipt",
"summary": "pos_es_receipt",
"version": "8.0.1.0",
"category": "Point Of Sale",
"website": "http://www.difusionvisual.com",
"author": "Difusión Visual",
"license": "AGPL-3",
"application": False,
"installable": True,
"depends": [
"base",
"point_of_sale",
],
"qweb": [
'static/src/xml/receipt.xml'
],
"data":["views/pos_es_receipt.xml"]
}
S'il vous plaît me dire comment ajouter une action onClick sur bouton Imprimer Détail
J'ai essayé ceci. mais il fonctionne en mode débogage. En mode normal, le champ n'est pas imprimé en réception. –