I have a problem with my OpenERP v7 POS module. I print my POS sales on A4 format with pos.order name field on it (Order Ref, not the Receipt Ref (pos_reference)), for that I have this modification on /point_of_sale/static/src/img/js/screens.js (not my code, I think the creator was Akshay)
(...) |
And other pos module with pos.js like this:
|
And pos.xml where it calls the print_order_number_A4
<?xml version="1.0" encoding="UTF-8"?> <templates id="template" xml:space="preserve">
<t t-extend="ProductScreenWidget"> <t t-jquery="tr.header-row" t-operation="before"> <tr class="selection-area"> <td style="padding-top: 7px;"> <span class='button_select' id="customer_link"> Selecionar Cliente </span> </td> </tr> </t> </t> <t t-extend="OrderButtonWidget"> <t t-jquery="li.order-selector-button" t-operation="replace"> <li class="order-selector-button"> <button class="select-order"><t t-esc="(widget.order.get_client() ? widget.order.get_client()+' : ':'') + widget.order.get('creationDate').toString('t')"/></button> </li> </t> </t>
<t t-name="ProductWidget"> <li class='product'> <a href="#"> <div class="product-img"> <img src='' /> <!-- the product thumbnail --> <t t-if="!widget.model.get('to_weight')"> <span class="price-tag"> <t t-esc="widget.format_currency(widget.model.get('price'))"/> </span> </t> <t t-if="widget.model.get('to_weight')"> <span class="price-tag"> <t t-esc="widget.format_currency(widget.model.get('price'))+'/Kg'"/> </span> </t> </div> <div class="product-name"> <t t-esc="widget.model.get('name')"/> </div> <div class="product-qty"> <t t-if="widget.model.get('qty_available') <= 0"> <div class="product-qty-neg"> <t t-esc="widget.model.get('qty_available')"/> </div> </t> <t t-if="widget.model.get('qty_available') > 0"> <t t-esc="widget.model.get('qty_available')"/> </t> </div> </a> </li> </t> <!-- <t t-extend="PosTicket"> --> <!-- <t t-jquery="div.pos-sale-ticket t:nth-child(7)" t-operation="after"><br /> --> <!-- Customer Name: <t t-esc="widget.currentOrder.get_client_name()"/> --> <!-- </t> --> <!-- </t> --> <t t-extend="PosTicket"> <t t-jquery="div.pos-sale-ticket" t-operation="replace"> <t t-if="widget.company.can_pos_receipt_in_A4 == false"> <div class="pos-sale-ticket"> <div class="pos-right-align"><t t-esc="new Date().toString(Date.CultureInfo.formatPatterns.shortDate + ' ' + Date.CultureInfo.formatPatterns.longTime)"/> <t t-esc="widget.currentOrder.attributes.name"/></div> <br /> <t t-esc="widget.company.name"/><br /> Phone: <t t-esc="widget.company.phone || ''"/><br /> User: <t t-esc="widget.user.name"/><br /> Cliente: <t t-esc="widget.currentOrder.get_client_name()"/><br /> No.: <t t-esc="widget.currentOrder.get_client_id()"/><br /> Loja: <t t-esc="widget.shop_obj.name"/><br /> <br /> <table> <colgroup> <col width='50%' /> <col width='25%' /> <col width='25%' /> </colgroup> <tr t-foreach="widget.currentOrderLines.toArray()" t-as="orderline"> <td> <t t-esc="orderline.get_product().get('name')"/> <t t-if="orderline.get_discount() > 0"> <div class="pos-disc-font"> With a <t t-esc="orderline.get_discount()"/>% discount </div> </t> </td> <td class="pos-right-align"> <t t-esc="orderline.get_quantity_str_with_unit()"/> </td> <td class="pos-right-align"> <t t-esc="widget.format_currency(orderline.get_product().get('price'))"/> </td> </tr> </table> <br /> <table> <tr><td>Subtotal:</td><td class="pos-right-align"> <t t-esc="widget.format_currency(widget.currentOrder.getSubtotal())"/> </td></tr> <tr><td>Tax:</td><td class="pos-right-align"> <t t-esc="widget.format_currency(widget.currentOrder.getTax())"/> </td></tr> <tr><td>Discount:</td><td class="pos-right-align"> <t t-esc="widget.format_currency(widget.currentOrder.getDiscountTotal())"/> </td></tr> <tr class="emph"><td>Total:</td><td class="pos-right-align"> <t t-esc="widget.format_currency(widget.currentOrder.getTotalTaxIncluded())"/> </td></tr> </table> <br /> <table> <tr t-foreach="widget.currentPaymentLines.toArray()" t-as="pline"> <td> <t t-esc="pline.get_cashregister().get('journal_id')[1]"/> </td> <td class="pos-right-align"> <t t-esc="widget.format_currency(pline.get_amount())"/> </td> </tr> </table> <br /> <table> <tr><td>Change:</td><td class="pos-right-align"> <t t-esc="widget.format_currency(widget.currentOrder.getPaidTotal() - widget.currentOrder.getTotalTaxIncluded())"/> </td></tr> </table> </div> </t> <!--Print Receipt for A4 -->
<t t-if="widget.company.can_pos_receipt_in_A4"> <div class="pos-sale-ticket_A4" style=" width: 680px;"> <div class="er_container"> <div style="align:left;width=40%;" id="company_logo"><img t-att-src="'data:image/png;base64,'+ widget.company.logo" width="40%"/></div> <br /> <div class="er_address">
<div style="float:left;width:45%;"> <t t-esc="widget.company.name" /><br /> <!--Shop: <t t-esc="widget.shop_obj.name"/> <br />--> <t t-if="widget.company.street"> <t t-esc="widget.company.street || ''"/> <br /> </t> <t t-if="widget.company.city"> <t t-esc="widget.company.city || '' "/> <br /> </t> NIF : <t t-esc="widget.company.company_registry || ''"/><br /> <t t-if="widget.company.phone"> <t t-esc="widget.company.phone || ''"/> <br /> </t> <t t-if="widget.company.email"> <t t-esc="widget.company.email || ''"/> </t> </div>
<div style="text-align:left; float:right;width:40%;margin-right: 12px;"> <t t-esc="widget.currentOrder.get_client_name()" /><br /> <!--<t t-esc="widget.currentOrder.get_client_vat()" />-->
</div>
<div style="clear: both;" /> <br /><br />
<div class="er_v_dinheiro"> <b> <span id="print_order_number_A4"></span> </b> <br /> <!--Ref No: <b> <t t-esc="widget.currentOrder.getName()" /></b>--> </div>
<div style="clear: both;" /> <br /> <div style="clear: both;" />
<div class="er_data_table" style="width: 101%;"> <div class="er_data_tr"> <div class="er_data_th">Operador</div> <div class="er_data_th">Data da Fatura</div> <div class="er_data_th">Cod. Cliente</div> </div>
<div class="er_data_tr"> <div class="er_data_td"><t t-esc="widget.user.name"/></div> <div class="er_data_td"><t t-esc="new Date().toString(Date.CultureInfo.formatPatterns.shortDate + ' ' + Date.CultureInfo.formatPatterns.shortTime)"/></div> <div class="er_data_td"> n.º <t t-if="widget.currentOrder.get_client_id()"> <t t-if="widget.currentOrder.get_client_id()"> <t t-esc="widget.currentOrder.get_client_id()"/> </t> <t t-if="widget.currentOrder.get_client_id() == false"> - </t> </t> </div> </div> </div> </div> <!--<div style="text-align:left; float:right;width:40%;margin-right: 12px;"> Customer Name: <t t-esc="widget.currentOrder.get_client_name()"/> </div>-->
<div style="clear: both;"> <br /> </div> <div class="er_order_line_table"> <div class="er_order_line_tr"> <div class="er_order_line_discription_th" style="width:47%;">Descrição</div> <div style="width:6%;" class="er_order_line_th_qty">Quant.</div> <div class="er_order_line_th" align="center" style="width:21%;">Preço Un.</div> <div class="er_order_line_th_qty" align="center" style="width:13%;">Desc.(%)</div> <div class="er_order_line_th" align="right" style="width:13%;">Preço</div> </div>
<div style="clear: both;" />
<hr /> <table width="100%" > <tr class="er_order_line_tr" t-foreach="widget.currentOrderLines.toArray()" t-as="orderline"> <td class="er_order_line_discription_td" style="width:47%;"> <t t-if="orderline.get_product().get('default_code')"> <t t-esc="orderline.get_product().get('default_code')"/> - </t> <t t-esc="orderline.get_product().get('name')"/> </td> <td class="er_order_line_td_qty" align="center" style="width:6%;"> <t t-esc="orderline.get_quantity_str_with_unit()"/>
</td> <td class="er_order_line_td" align="center" style="width:21%;"> <t t-esc="widget.format_currency(orderline.get_product().get('price'))"/> </td> <td class="er_order_line_td_qty" align="center" style="width:13%;"> <t t-if="orderline"> <t t-if="orderline.get_discount() == false">-</t> <t t-if="orderline.get_discount() > 0"> <t t-esc="orderline.get_discount()"/>%</t> </t> </td> <td class="er_order_line_td" align="right" style="width:13%;"> <t t-esc="widget.format_currency(orderline.get_product().get('price') * (1 - orderline.get_discount()/100) * orderline.get_quantity())"/> </td> </tr> </table> </div> <div style="clear: both;" /> <!--<br /> <table class="er_table"> <tr class="er_order_line_tr"> <th class="er_order_line_discription_th">Product Description</th> <th class="pos-right-align" >Quantity</th> <th class="pos-right-align">Price </th> </tr> <tr t-foreach="widget.currentOrderLines.toArray()" t-as="orderline"> <td> <t t-esc="orderline.get_product().get('name')"/> <t t-if="orderline.get_discount() > 0"> <div class="pos-disc-font"> With a <t t-esc="orderline.get_discount()"/>% discount </div> </t> </td> <td class="pos-right-align"> <t t-esc="orderline.get_quantity_str_with_unit()"/> </td> <td class="pos-right-align"> <t t-esc="widget.format_currency(orderline.get_display_price())"/> </td> </tr> </table>-->
<br />
<hr width="38%" align="right"/> <div style="clear: both;" /> <table class="er_total_container"> <!--<tr><td>Subtotal:</td><td class="pos-right-align"> <t t-esc="widget.format_currency(widget.currentOrder.getSubtotal())"/> </td></tr> <tr><td>Tax:</td><td class="pos-right-align"> <t t-esc="widget.format_currency(widget.currentOrder.getTax())"/> </td></tr>--> <tr><td>Discount:</td><td class="pos-right-align"> <t t-esc="widget.format_currency(widget.currentOrder.getDiscountTotal())"/> </td></tr> <tr><td>Change:</td><td class="pos-right-align"> <t t-esc="widget.format_currency(widget.currentOrder.getPaidTotal() - widget.currentOrder.getTotalTaxIncluded())"/> </td></tr> <tr class="emph"><td>Total:</td><td class="pos-right-align"> <t t-esc="widget.format_currency(widget.currentOrder.getTotalTaxIncluded())"/> </td></tr> </table> <div style="clear: both;" /> <br /><br /><br /> <hr /> <div style="clear: both;" /> <table class="er_table"> <tr t-foreach="widget.currentPaymentLines.toArray()" t-as="pline"> <td> <t t-esc="pline.get_cashregister().get('journal_id')[1]"/> </td> <td class="pos-right-align"> <t t-esc="widget.format_currency(pline.get_amount())"/> </td> </tr> </table> <br /> <!--<table width="100%"> <tr><td>Change:</td><td class="pos-right-align"> <t t-esc="widget.format_currency(widget.currentOrder.getPaidTotal() - widget.currentOrder.getTotalTaxIncluded())"/> </td></tr> <div style="clear: both;" /> </table>--> <div style="clear: both;" /> <br /><br /><br /><br /><br /> <div style="clear: both;" /> <hr /> <div style="clear: both;" /> <div class="er_footer"> <t t-if="widget.company.phone"> <t t-esc="widget.company.phone"/> - </t> <t t-if="widget.company.website"> <t t-esc="widget.company.website"/> - </t> <t t-if="widget.company.company_registry"> NIF: <t t-esc="widget.company.company_registry"/> </t> </div> </div> </div> </t> </t> </t>
</templates> |
So I know that the problem is that ir.sequence are called two times (one on screen.js, the other on def create, line 673 of point_of_sale.py) so it create two numbers for one sale (one is printed on the front end POS, the other goes stored on database and shows on pos orders list). What should I do to fix it and still get the Order Ref on A4 POS print receipt?