| @ -0,0 +1,21 @@ | |||
| ================== | |||
| Pos Old Orders v10 | |||
| ================== | |||
| 
 | |||
| This module adds new options for listing the old orders and printing the corresponding receipts. | |||
| 
 | |||
| Installation | |||
| ============ | |||
| 
 | |||
| Just select it from available modules to install it, there is no need to extra installations. | |||
| 
 | |||
| Configuration | |||
| ============= | |||
| 
 | |||
| Nothing to configure. | |||
| 
 | |||
| Credits | |||
| ======= | |||
| Developer: Linto CT @ cybrosys, linto@cybrosys.in | |||
| 
 | |||
| 
 | |||
| @ -0,0 +1,26 @@ | |||
| # -*- coding: utf-8 -*- | |||
| 
 | |||
| ############################################################################## | |||
| # | |||
| #    Cybrosys Technologies Pvt. Ltd. | |||
| #    Copyright (C) 2017-TODAY Cybrosys Technologies(<https://www.cybrosys.com>). | |||
| #    Author: LINTO C T(<https://www.cybrosys.com>) | |||
| #    you can modify it under the terms of the GNU LESSER | |||
| #    GENERAL PUBLIC LICENSE (LGPL v3), Version 3. | |||
| # | |||
| #    It is forbidden to publish, distribute, sublicense, or sell copies | |||
| #    of the Software or modified copies of the Software. | |||
| # | |||
| #    This program is distributed in the hope that it will be useful, | |||
| #    but WITHOUT ANY WARRANTY; without even the implied warranty of | |||
| #    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the | |||
| #    GNU LESSER GENERAL PUBLIC LICENSE (LGPL v3) for more details. | |||
| # | |||
| #    You should have received a copy of the GNU LESSER GENERAL PUBLIC LICENSE | |||
| #    GENERAL PUBLIC LICENSE (LGPL v3) along with this program. | |||
| #    If not, see <https://www.gnu.org/licenses/>. | |||
| # | |||
| ############################################################################## | |||
| 
 | |||
| import models | |||
| import report | |||
| @ -0,0 +1,43 @@ | |||
| # -*- coding: utf-8 -*- | |||
| 
 | |||
| ############################################################################## | |||
| # | |||
| #    Cybrosys Technologies Pvt. Ltd. | |||
| #    Copyright (C) 2017-TODAY Cybrosys Technologies(<https://www.cybrosys.com>). | |||
| #    Author: LINTO C T(<https://www.cybrosys.com>) | |||
| #    you can modify it under the terms of the GNU LESSER | |||
| #    GENERAL PUBLIC LICENSE (LGPL v3), Version 3. | |||
| # | |||
| #    It is forbidden to publish, distribute, sublicense, or sell copies | |||
| #    of the Software or modified copies of the Software. | |||
| # | |||
| #    This program is distributed in the hope that it will be useful, | |||
| #    but WITHOUT ANY WARRANTY; without even the implied warranty of | |||
| #    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the | |||
| #    GNU LESSER GENERAL PUBLIC LICENSE (LGPL v3) for more details. | |||
| # | |||
| #    You should have received a copy of the GNU LESSER GENERAL PUBLIC LICENSE | |||
| #    GENERAL PUBLIC LICENSE (LGPL v3) along with this program. | |||
| #    If not, see <https://www.gnu.org/licenses/>. | |||
| # | |||
| ############################################################################## | |||
| { | |||
|     'name': 'Order Reprinting In POS', | |||
|     'version': '10.0.1.0.0', | |||
|     'category': 'Point of Sale', | |||
|     'summary': 'POS Order Reprinting', | |||
|     'author': 'Cybrosys Techno Solutions', | |||
|     'company': 'Cybrosys Techno Solutions', | |||
|     'images': ['static/description/banner.jpg'], | |||
|     'website': 'https://www.cybrosys.com', | |||
|     'depends': ['point_of_sale'], | |||
|     'data': [ | |||
|              'report/receipt_report.xml', | |||
|              'views/pos_template.xml', | |||
|              'views/point_of_sale_report.xml', | |||
|             ], | |||
|     'qweb': ['static/src/xml/pos.xml'], | |||
|     'images': ['static/description/banner.jpg'], | |||
|     'installable': True, | |||
|     'auto_install': False, | |||
| } | |||
| @ -0,0 +1,3 @@ | |||
| # -*- coding: utf-8 -*- | |||
| 
 | |||
| import pos_orderline | |||
| @ -0,0 +1,61 @@ | |||
| # -*- coding: utf-8 -*- | |||
| 
 | |||
| from odoo import models, fields, api | |||
| 
 | |||
| 
 | |||
| class PosOrderLines(models.Model): | |||
|     _inherit = 'pos.order' | |||
| 
 | |||
|     @api.model | |||
|     def _default_currency(self): | |||
|         return self.env.user.company_id.currency_id | |||
| 
 | |||
|     currency_id = fields.Many2one('res.currency', string='Currency', | |||
|         required=True, readonly=True, default=_default_currency, track_visibility='always') | |||
| 
 | |||
|     @api.model | |||
|     def print_receipt(self): | |||
|         return { | |||
|             'type': 'ir.actions.client', | |||
|             'tag': 'aek_browser_pdf', | |||
|             'params': { | |||
|                 'report_name': 'order_reprinting_pos.report_pos_reciept_new', | |||
|                 'ids': self.ids, | |||
|                 'datas': ["bjhg,jh"], | |||
|             } | |||
|         } | |||
| 
 | |||
|     @api.model | |||
|     def get_details(self, ref): | |||
|         order_id = self.env['pos.order'].sudo().search([('pos_reference', '=', ref)], limit=1) | |||
|         return order_id.ids | |||
| 
 | |||
|     @api.model | |||
|     def get_orderlines(self, ref): | |||
|         discount = 0 | |||
|         result = [] | |||
|         order_id = self.search([('pos_reference', '=', ref)], limit=1) | |||
|         lines = self.env['pos.order.line'].search([('order_id', '=', order_id.id)]) | |||
|         payments = self.env['account.bank.statement.line'].search([('pos_statement_id', '=', order_id.id)]) | |||
|         payment_lines = [] | |||
|         change = 0 | |||
|         for i in payments: | |||
|             if i.amount > 0: | |||
|                 temp = { | |||
|                     'amount': i.amount, | |||
|                     'name': i.journal_id.name | |||
|                 } | |||
|                 payment_lines.append(temp) | |||
|             else: | |||
|                 change += i.amount | |||
|         for line in lines: | |||
|             new_vals = { | |||
|                 'product_id': line.product_id.name, | |||
|                 'qty': line.qty, | |||
|                 'price_unit': line.price_unit, | |||
|                 'discount': line.discount, | |||
|                 } | |||
|             discount += (line.price_unit * line.qty * line.discount) / 100 | |||
|             result.append(new_vals) | |||
| 
 | |||
|         return [result, discount, payment_lines, change] | |||
| @ -0,0 +1,25 @@ | |||
| # -*- coding: utf-8 -*- | |||
| 
 | |||
| ############################################################################## | |||
| # | |||
| #    Cybrosys Technologies Pvt. Ltd. | |||
| #    Copyright (C) 2017-TODAY Cybrosys Technologies(<https://www.cybrosys.com>). | |||
| #    Author: LINTO C T(<https://www.cybrosys.com>) | |||
| #    you can modify it under the terms of the GNU LESSER | |||
| #    GENERAL PUBLIC LICENSE (LGPL v3), Version 3. | |||
| # | |||
| #    It is forbidden to publish, distribute, sublicense, or sell copies | |||
| #    of the Software or modified copies of the Software. | |||
| # | |||
| #    This program is distributed in the hope that it will be useful, | |||
| #    but WITHOUT ANY WARRANTY; without even the implied warranty of | |||
| #    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the | |||
| #    GNU LESSER GENERAL PUBLIC LICENSE (LGPL v3) for more details. | |||
| # | |||
| #    You should have received a copy of the GNU LESSER GENERAL PUBLIC LICENSE | |||
| #    GENERAL PUBLIC LICENSE (LGPL v3) along with this program. | |||
| #    If not, see <https://www.gnu.org/licenses/>. | |||
| # | |||
| ############################################################################## | |||
| 
 | |||
| import pos_invoice | |||
| @ -0,0 +1,34 @@ | |||
| # -*- coding: utf-8 -*- | |||
| 
 | |||
| ############################################################################## | |||
| # | |||
| #    Cybrosys Technologies Pvt. Ltd. | |||
| #    Copyright (C) 2017-TODAY Cybrosys Technologies(<https://www.cybrosys.com>). | |||
| #    Author: LINTO C T(<https://www.cybrosys.com>) | |||
| #    you can modify it under the terms of the GNU LESSER | |||
| #    GENERAL PUBLIC LICENSE (LGPL v3), Version 3. | |||
| # | |||
| #    It is forbidden to publish, distribute, sublicense, or sell copies | |||
| #    of the Software or modified copies of the Software. | |||
| # | |||
| #    This program is distributed in the hope that it will be useful, | |||
| #    but WITHOUT ANY WARRANTY; without even the implied warranty of | |||
| #    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the | |||
| #    GNU LESSER GENERAL PUBLIC LICENSE (LGPL v3) for more details. | |||
| # | |||
| #    You should have received a copy of the GNU LESSER GENERAL PUBLIC LICENSE | |||
| #    GENERAL PUBLIC LICENSE (LGPL v3) along with this program. | |||
| #    If not, see <https://www.gnu.org/licenses/>. | |||
| # | |||
| ############################################################################## | |||
| 
 | |||
| from odoo import api, models | |||
| 
 | |||
| 
 | |||
| class PosReceiptReport(models.AbstractModel): | |||
|     _name = 'report.point_of_sale.report_receipts' | |||
| 
 | |||
|     @api.model | |||
|     def render_html(self, docids, data=None): | |||
|         Report = self.env['report'] | |||
|         return Report.sudo().render('order_reprinting_pos.receipt_report', {'docs': self.env['pos.order'].sudo().browse(docids)}) | |||
| @ -0,0 +1,98 @@ | |||
| <?xml version="1.0" encoding="utf-8"?> | |||
| <odoo> | |||
|     <data> | |||
|         <template id="receipt_report_document"> | |||
|             <t t-call="report.external_layout"> | |||
|                 <t t-set="o" t-value="o.with_context({'lang':o.partner_id.lang})" /> | |||
|                 <div class="page"> | |||
|                     <div class="row"> | |||
|                     </div> | |||
| 
 | |||
|                     <h2> | |||
|                         <span >Receipt</span> | |||
|                     </h2> | |||
| 
 | |||
|                     <div class="row mt32 mb32"> | |||
|                         <div class="col-xs-4" t-if="o.pos_reference"> | |||
|                             <strong>Ref: </strong> | |||
|                             <span t-esc="o.pos_reference" /> | |||
|                         </div> | |||
|                         <div class="col-xs-4" t-if="o.date_order"> | |||
|                             <strong>Date:</strong> | |||
|                             <p t-field="o.date_order"/> | |||
|                         </div> | |||
| 
 | |||
|                         <div class="col-xs-4" t-if="o.partner_id"> | |||
|                             <strong>Customer :</strong> | |||
|                             <p t-field="o.partner_id.name"/> | |||
|                         </div> | |||
|                     </div> | |||
| 
 | |||
|                     <!-- Is there a discount on at least one line? --> | |||
|                     <t t-set="display_discount" t-value="any([l.discount for l in o.lines])"/> | |||
| 
 | |||
|                     <table class="table table-condensed"> | |||
|                         <thead> | |||
|                             <tr> | |||
|                                 <th>Description</th> | |||
|                                 <th class="text-right">Quantity</th> | |||
|                                 <th class="text-right">Unit Price</th> | |||
|                                 <th t-if="display_discount" class="text-right">Disc.(%)</th> | |||
|                                 <th class="text-right">Taxes</th> | |||
|                                 <th class="text-right">Tax Excluded Price</th> | |||
|                             </tr> | |||
|                         </thead> | |||
|                         <tbody class="invoice_tbody"> | |||
|                             <tr t-foreach="o.lines" t-as="l"> | |||
|                                 <td><span t-field="l.name"/></td> | |||
|                                 <td class="text-right"> | |||
|                                     <span t-field="l.qty"/> | |||
|                                 </td> | |||
|                                 <td class="text-right"> | |||
|                                     <span t-field="l.price_unit"/> | |||
|                                 </td> | |||
|                                 <td t-if="display_discount" class="text-right"> | |||
|                                     <span t-field="l.discount"/> | |||
|                                 </td> | |||
|                                 <td class="text-right"> | |||
|                                     <span t-esc="', '.join(map(lambda x: (x.description or x.name), l.tax_ids_after_fiscal_position))"/> | |||
|                                 </td> | |||
|                                 <td class="text-right"> | |||
|                                     <span t-field="l.price_subtotal" | |||
|                                         t-options='{"widget": "monetary", "display_currency": o.currency_id}'/> | |||
|                                 </td> | |||
|                             </tr> | |||
|                         </tbody> | |||
|                     </table> | |||
| 
 | |||
|                     <div class="row"> | |||
|                         <div class="col-xs-4 pull-right"> | |||
|                             <table class="table table-condensed"> | |||
|                                 <tr class="border-black"> | |||
|                                     <td><strong>Tax</strong></td> | |||
|                                     <td class="text-right"> | |||
|                                         <span t-field="o.amount_tax" t-options='{"widget": "monetary", "display_currency": o.currency_id}'/> | |||
|                                     </td> | |||
|                                 </tr> | |||
|                                 <tr class="border-black"> | |||
|                                     <td><strong>Total</strong></td> | |||
|                                     <td class="text-right"> | |||
|                                          <span t-field="o.amount_total" t-options='{"widget": "monetary", "display_currency": o.currency_id}'/> | |||
|                                     </td> | |||
|                                 </tr> | |||
|                             </table> | |||
|                         </div> | |||
|                     </div> | |||
|                 </div> | |||
|             </t> | |||
|         </template> | |||
| 
 | |||
|         <template id="receipt_report"> | |||
|             <t t-call="report.html_container"> | |||
|                 <t t-foreach="docs" t-as="o"> | |||
|                     <t t-call="order_reprinting_pos.receipt_report_document" t-lang="o.partner_id.lang"/> | |||
|                 </t> | |||
|             </t> | |||
|         </template> | |||
|     </data> | |||
| </odoo> | |||
| After Width: | Height: | Size: 108 KiB | 
| After Width: | Height: | Size: 50 KiB | 
| After Width: | Height: | Size: 15 KiB | 
| @ -0,0 +1,92 @@ | |||
| <section class="oe_container"> | |||
|     <div class="oe_row oe_spaced"> | |||
|         <h2 class="oe_slogan">POS Old Orders</h2> | |||
|         <h3 class="oe_slogan">Order Reprinting POS</h3> | |||
|         <h4 class="oe_slogan">Cybrosys Technologies , www.cybrosys.com</h4> | |||
|      </div> | |||
| </section> | |||
| 
 | |||
| <section class="oe_container oe_dark"> | |||
|      <div class="oe_row oe_spaced"> | |||
|         <div class="oe_row oe_spaced"> | |||
|             <div class="oe_span12"> | |||
|                 <p class="oe_mt32"> | |||
|                     This module allows us to list the previous orders and take a printout of each order. | |||
|                     A new button is added for this purpose. When we click on this button a new list | |||
|                     will appear, which will show all the previous orders. Once we have validated an order, or | |||
|                     created an invoice, the corresponding order will be updated in this list. We don't need to | |||
|                     refresh the browser or close the session. It is also possible to search among the list with order reference. | |||
|                 </p> | |||
|             </div> | |||
| 
 | |||
|         </div> | |||
|      </div> | |||
| </section> | |||
| 
 | |||
| <section class="oe_container"> | |||
|      <div class="oe_row oe_spaced"> | |||
|         <div class="oe_row oe_spaced"> | |||
|             <div class="oe_span12"> | |||
|                 <center> | |||
|                 <div class="oe_row_img oe_centered"> | |||
|                     <img class="oe_picture oe_screenshot" src="order-button.png"> | |||
|                 </div> | |||
|                 </center> | |||
|                 <p class="oe_mt32">By clicking on the 'Orders' button, we can see all orders list.</p> | |||
|                 <div class="oe_row_img oe_centered"> | |||
|                     <img class="oe_picture oe_screenshot" src="orders-list.png"> | |||
|                 </div> | |||
|                 <p class="oe_mt32"> | |||
|                     We can search orders by their reference. For each order, we can see a button 'Print'. By clicking on this button, we can see the | |||
|                     details of that particular order. | |||
|                 </p> | |||
|             </div> | |||
|         </div> | |||
|      </div> | |||
| </section> | |||
| 
 | |||
| <section class="oe_container oe_dark"> | |||
|      <div class="oe_row oe_spaced"> | |||
|         <div class="oe_row oe_spaced"> | |||
|             <div class="oe_span12"> | |||
|                 <center> | |||
|                     <div class="oe_row_img oe_centered"> | |||
|                         <img class="oe_picture oe_screenshot" src="old-receipt.png"> | |||
|                     </div> | |||
|                     <p class="oe_mt32"> | |||
|                          The 'Print Receipt' button can be used to download this order in a pdf file. | |||
|                     </p> | |||
|                     <div class="oe_row_img oe_centered"> | |||
|                         <img class="oe_picture oe_screenshot" src="order-re-pdf.png"> | |||
|                     </div> | |||
|                 </center> | |||
|             </div> | |||
|         </div> | |||
|      </div> | |||
| </section> | |||
| 
 | |||
| <section class="oe_container"> | |||
|         <h2 class="oe_slogan" style="margin-top:20px;" >Need Any Help?</h2> | |||
|         <div class="oe_slogan" style="margin-top:10px !important;"> | |||
|             <div> | |||
|                 <a  class="btn btn-primary btn-lg mt8" | |||
|                 style="color: #FFFFFF !important;border-radius: 0;" href="https://www.cybrosys.com"><i | |||
|                 class="fa fa-envelope"></i> Email </a> <a | |||
|                 class="btn btn-primary btn-lg mt8" style="color: #FFFFFF !important;border-radius: 0;" | |||
|                 href="https://www.cybrosys.com/contact/"><i | |||
|                 class="fa fa-phone"></i> Contact Us </a> <a | |||
|                 class="btn btn-primary btn-lg mt8" style="color: #FFFFFF !important;border-radius: 0;" | |||
|                 href="https://www.cybrosys.com/odoo-customization-and-installation/"><i | |||
|                 class="fa fa-check-square"></i> Request Customization </a> | |||
|             </div> | |||
|             <br> | |||
|             <img src="cybro_logo.png" style="width: 190px; margin-bottom: 20px;" class="center-block"> | |||
|             <div> | |||
|               <a href="https://twitter.com/cybrosys" target="_blank"><i class="fa fa-2x fa-twitter" style="color:white;background: #00a0d1;width:35px;"></i></a></td> | |||
|               <a href="https://www.linkedin.com/company/cybrosys-technologies-pvt-ltd" target="_blank"><i class="fa fa-2x fa-linkedin" style="color:white;background: #31a3d6;width:35px;padding-left: 3px;"></i></a></td> | |||
|               <a href="https://www.facebook.com/cybrosystechnologies" target="_blank"><i class="fa fa-2x fa-facebook" style="color:white;background: #3b5998;width:35px;padding-left: 8px;"></i></a></td> | |||
|               <a href="https://plus.google.com/106641282743045431892/about" target="_blank"><i class="fa fa-2x fa-google-plus" style="color:white;background: #c53c2c;width:35px;padding-left: 3px;"></i></a></td> | |||
|               <a href="https://in.pinterest.com/cybrosys" target="_blank"><i class="fa fa-2x fa-pinterest" style="color:white;background: #ac0f18;width:35px;padding-left: 3px;"></i></a></td> | |||
|             </div> | |||
|         </div> | |||
| </section> | |||
| After Width: | Height: | Size: 29 KiB | 
| After Width: | Height: | Size: 4.1 KiB | 
| After Width: | Height: | Size: 25 KiB | 
| After Width: | Height: | Size: 102 KiB | 
| @ -0,0 +1,7 @@ | |||
| .screen .centered-content-new{ | |||
|     position: absolute !important; | |||
|     right:25%; top: 64px !important; bottom: 0px !important; | |||
|     left:25% !important; | |||
|     border-right: dashed 1px rgb(215,215,215) !important; | |||
|     border-left: dashed 1px rgb(215,215,215) !important; | |||
| } | |||
| @ -0,0 +1,295 @@ | |||
| odoo.define('order_reprinting_pos',function(require) { | |||
| "use strict"; | |||
| 
 | |||
| var gui = require('point_of_sale.gui'); | |||
| var chrome = require('point_of_sale.chrome'); | |||
| var popups = require('point_of_sale.popups'); | |||
| var core = require('web.core'); | |||
| var models = require('point_of_sale.models'); | |||
| var PosModelSuper = models.PosModel; | |||
| var pos_screens = require('point_of_sale.screens'); | |||
| var Model = require('web.DataModel'); | |||
| var QWeb = core.qweb; | |||
| var _t = core._t; | |||
| 
 | |||
| models.load_models({ | |||
|             model: 'pos.order', | |||
|             fields: ['id', 'name', 'session_id', 'pos_reference', 'partner_id', 'amount_total', 'amount_tax'], | |||
|             loaded: function (self, pos_orders) { | |||
|                 var new_order_list = []; | |||
|                 for (var i in pos_orders){ | |||
|                     new_order_list[pos_orders[i].id] = pos_orders[i]; | |||
|                 } | |||
|                 self.pos_orders = new_order_list; | |||
|             }, | |||
|         }); | |||
| 
 | |||
| var DomCache = core.Class.extend({ | |||
|         init: function(options){ | |||
|             options = options || {}; | |||
|             this.max_size = options.max_size || 2000; | |||
| 
 | |||
|             this.cache = {}; | |||
|             this.access_time = {}; | |||
|             this.size = 0; | |||
|         }, | |||
|         cache_node: function(key,node){ | |||
|             var cached = this.cache[key]; | |||
|             this.cache[key] = node; | |||
|             this.access_time[key] = new Date().getTime(); | |||
|             if(!cached){ | |||
|                 this.size++; | |||
|                 while(this.size >= this.max_size){ | |||
|                     var oldest_key = null; | |||
|                     var oldest_time = new Date().getTime(); | |||
|                     for(key in this.cache){ | |||
|                         var time = this.access_time[key]; | |||
|                         if(time <= oldest_time){ | |||
|                             oldest_time = time; | |||
|                             oldest_key  = key; | |||
|                         } | |||
|                     } | |||
|                     if(oldest_key){ | |||
|                         delete this.cache[oldest_key]; | |||
|                         delete this.access_time[oldest_key]; | |||
|                     } | |||
|                     this.size--; | |||
|                 } | |||
|             } | |||
|             return node; | |||
|         }, | |||
|         clear_node: function(key) { | |||
|             var cached = this.cache[key]; | |||
|             if (cached) { | |||
|                 delete this.cache[key]; | |||
|                 delete this.access_time[key]; | |||
|                 this.size --; | |||
|             } | |||
|         }, | |||
|         get_node: function(key){ | |||
|             var cached = this.cache[key]; | |||
|             if(cached){ | |||
|                 this.access_time[key] = new Date().getTime(); | |||
|             } | |||
|             return cached; | |||
|         }, | |||
|     }); | |||
| chrome.OrderSelectorWidget.include({ | |||
|     renderElement: function(){ | |||
|         var self = this; | |||
|         this._super(); | |||
|         this.$('.orders-list').click(function(event){ | |||
|             self.gui.show_screen('OldOrdersWidget'); | |||
|         }); | |||
|     }, | |||
| }); | |||
| 
 | |||
| models.PosModel = models.PosModel.extend({ | |||
|     _save_to_server: function (orders, options) { | |||
|         var result_new = PosModelSuper.prototype._save_to_server.call(this, orders, options); | |||
|         var self = this; | |||
|         var new_order = {}; | |||
|         var order_list = self.pos_orders; | |||
|         for (var i in orders) { | |||
|             var partners = self.partners; | |||
|             var partner = ""; | |||
|             for(var j in partners){ | |||
|                 if(partners[j].id == orders[i].data.partner_id){ | |||
|                     partner = partners[j].name; | |||
|                 } | |||
|             } | |||
|             new_order = { | |||
|                 'amount_tax': orders[i].data.amount_tax, | |||
|                 'amount_total': orders[i].data.amount_total, | |||
|                 'pos_reference': orders[i].data.name, | |||
|                 'partner_id': [orders[i].data.partner_id, partner], | |||
|                 'session_id': [ | |||
|                     self.pos_session.id, self.pos_session.name | |||
|                 ] | |||
|             }; | |||
|             order_list.push(new_order); | |||
|             self.pos_orders = order_list; | |||
|             self.gui.screen_instances.OldOrdersWidget.render_list(order_list); | |||
|         } | |||
|         return result_new; | |||
|     }, | |||
| }); | |||
| 
 | |||
| var OldOrdersWidget = pos_screens.ScreenWidget.extend({ | |||
|     template: 'OldOrdersWidget', | |||
| 
 | |||
|     init: function(parent, options){ | |||
|         this._super(parent, options); | |||
|         this.order_cache = new DomCache(); | |||
|         this.order_string = ""; | |||
|         this.pos_reference = ""; | |||
|     }, | |||
| 
 | |||
|     auto_back: true, | |||
|     renderElement: function () { | |||
|         this._super(this); | |||
|         var self = this; | |||
|         this.$('.button.print').click(function(){ | |||
|             if (!self._locked) { | |||
|                 self.gui.screen_instances.receipt.print(); | |||
|             } | |||
|             new Model('pos.order').call('get_details',[self.pos_reference]).then(function(id){ | |||
|                 self.chrome.do_action('order_reprinting_pos.pos_receipt_report',{additional_context:{ | |||
|                     active_ids:[id], | |||
|                 }}); | |||
|             }); | |||
|         }); | |||
|     }, | |||
| 
 | |||
|     show: function(){ | |||
|         var self = this; | |||
|         this._super(); | |||
| 
 | |||
|         this.renderElement(); | |||
|         this.details_visible = false; | |||
| 
 | |||
|         this.$('.back').click(function(){ | |||
|             self.gui.back(); | |||
|         }); | |||
|         var pos_orders = this.pos.pos_orders; | |||
|         this.render_list(pos_orders); | |||
| 
 | |||
| 
 | |||
|         var search_timeout = null; | |||
| 
 | |||
|         if(this.pos.config.iface_vkeyboard && this.chrome.widget.keyboard){ | |||
|             this.chrome.widget.keyboard.connect(this.$('.searchbox input')); | |||
|         } | |||
| 
 | |||
|         this.$('.searchbox input').on('keypress',function(event){ | |||
|             clearTimeout(search_timeout); | |||
| 
 | |||
|             var query = this.value; | |||
|             search_timeout = setTimeout(function(){ | |||
|                 self.perform_search(query,event.which === 13); | |||
|             },70); | |||
|         }); | |||
| 
 | |||
|         this.$('.searchbox .search-clear').click(function(){ | |||
|             self.clear_search(); | |||
|         }); | |||
|     }, | |||
|     hide: function () { | |||
|         this._super(); | |||
|         this.new_client = null; | |||
|     }, | |||
|     perform_search: function(query, associate_result){ | |||
|         var new_orders; | |||
|         if(query){ | |||
|             new_orders = this.search_order(query); | |||
| 
 | |||
|             this.render_list(new_orders); | |||
|         }else{ | |||
|             var orders = this.pos.pos_orders; | |||
|             this.render_list(orders); | |||
|         } | |||
|     }, | |||
|     search_order: function(query){ | |||
|         var self = this; | |||
|         try { | |||
|             query = query.replace(/[\[\]\(\)\+\*\?\.\-\!\&\^\$\|\~\_\{\}\:\,\\\/]/g,'.'); | |||
|             query = query.replace(' ','.+'); | |||
|             var re = RegExp("([0-9]+):.*?"+query,"gi"); | |||
|         }catch(e){ | |||
|             return []; | |||
|         } | |||
|         var results = []; | |||
|         for(var i = 0; i < Math.min(self.pos.pos_orders.length,1000); i++){ | |||
|             var r = re.exec(this.order_string); | |||
|             if(r){ | |||
|                 var id = Number(r[1]); | |||
|                 results.push(this.get_order_by_id(id)); | |||
|             }else{ | |||
|                 break; | |||
|             } | |||
|         } | |||
|         return results; | |||
|     }, | |||
|     // returns the order with the id provided
 | |||
|     get_order_by_id: function (id) { | |||
|         return this.pos.pos_orders[id]; | |||
|     }, | |||
|     clear_search: function(){ | |||
|         var orders = this.pos.pos_orders; | |||
|         this.render_list(orders); | |||
|         this.$('.searchbox input')[0].value = ''; | |||
|         this.$('.searchbox input').focus(); | |||
|     }, | |||
|     render_list: function(orders){ | |||
|         var self = this; | |||
|         for(var i = 0, len = Math.min(orders.length,1000); i < len; i++) { | |||
|             if (orders[i]) { | |||
|                 var order = orders[i]; | |||
|                 self.order_string += i + ':' + order.pos_reference + '\n'; | |||
|             } | |||
|         } | |||
| 
 | |||
|         this.$('.order-list-contents').delegate('.print-button','click',function(event){ | |||
|             var pos_ref = $(this).data('id'); | |||
|             var order_new = null; | |||
|             for(var i = 0, len = Math.min(orders.length,1000); i < len; i++) { | |||
|                 if (orders[i] && orders[i].pos_reference == pos_ref) { | |||
|                     order_new = orders[i]; | |||
|                 } | |||
|             } | |||
|             $('span.searchbox').css('display', 'none'); | |||
|             $('.button.print').css('display', 'block'); | |||
|             var lines = []; | |||
|             var payments = []; | |||
|             var discount = 0; | |||
|             new Model('pos.order').call('get_orderlines',[order_new.pos_reference]).then(function(result){ | |||
|                 lines = result[0]; | |||
|                 payments = result[2]; | |||
|                 discount = result[1]; | |||
|                 self.gui.show_screen('OldOrdersWidget'); | |||
|                 self.$('.window').html(QWeb.render('PosTicketOld',{ | |||
|                     widget:self, | |||
|                     order: order_new, | |||
|                     change: result[3], | |||
|                     orderlines: lines, | |||
|                     discount_total: discount, | |||
|                     paymentlines: payments, | |||
|                 })); | |||
|                 self.pos_reference = order_new.pos_reference; | |||
|             }); | |||
|         }); | |||
|          | |||
|         var contents = this.$el[0].querySelector('.order-list-contents'); | |||
|         if (contents){ | |||
|             contents.innerHTML = ""; | |||
|             for(var i = 0, len = Math.min(orders.length,1000); i < len; i++) { | |||
|                 if (orders[i]) { | |||
|                     var order = orders[i]; | |||
| 
 | |||
|                     var orderline = this.order_cache.get_node(order.id); | |||
|                     if (!orderline) { | |||
|                         var clientline_html = QWeb.render('OrderLine', {widget: this, order: order}); | |||
|                         var orderline = document.createElement('tbody'); | |||
|                         orderline.innerHTML = clientline_html; | |||
|                         orderline = orderline.childNodes[1]; | |||
|                         if (order.id){ | |||
|                             this.order_cache.cache_node(order.id, orderline); | |||
|                         } | |||
|                         else{ | |||
|                             this.order_cache.cache_node(i, orderline); | |||
|                         } | |||
|                     } | |||
|                     contents.appendChild(orderline); | |||
|                 } | |||
|             } | |||
|         } | |||
|     }, | |||
|      | |||
|     close: function(){ | |||
|         this._super(); | |||
|     }, | |||
| }); | |||
| gui.define_screen({name:'OldOrdersWidget', widget: OldOrdersWidget}); | |||
| 
 | |||
| 
 | |||
| }); | |||
| @ -0,0 +1,154 @@ | |||
| <?xml version="1.0" encoding="UTF-8"?> | |||
| <templates id="template" xml:space="preserve"> | |||
|     <t t-extend="OrderSelectorWidget"> | |||
|         <t t-jquery="div.order-selector" t-operation="append"> | |||
|             <div> | |||
|                 <span class="order-button square orders-list"> | |||
|                     Orders | |||
|                 </span> | |||
|             </div> | |||
|         </t> | |||
|     </t> | |||
|     <t t-name="OrderLine"> | |||
|         <tr class='order-line' t-att-data-id='order.id'> | |||
|             <td><t t-esc='order.pos_reference' /></td> | |||
|             <td><t t-esc='order.partner_id[1]' /></td> | |||
|             <td><t t-esc='order.session_id[1]'/></td> | |||
|             <td><t t-esc='order.amount_total'/></td> | |||
|             <td class="print-button" t-att-data-id='order.pos_reference'><span >Print</span></td> | |||
|         </tr> | |||
|     </t> | |||
|     <t t-name="OldOrdersWidget"> | |||
|         <div class="clientlist-screen screen"> | |||
|             <div class="screen-content"> | |||
|                 <section class="top-content"> | |||
|                     <span class='button back'> | |||
|                         <i class='fa fa-angle-double-left'></i> | |||
|                         Cancel | |||
|                     </span> | |||
|                     <span class='searchbox' style="margin-left:217px !important;"> | |||
|                         <input placeholder='Search Orders by ref' /> | |||
|                         <span class='search-clear'></span> | |||
|                     </span> | |||
|                     <div class="centered-content-new" style="position:absolute;margin-left:12%;margin-top:-62px;width:20%;"> | |||
|                         <div class="button print" style="display:none;"> | |||
|                             <i class='fa fa-print'></i> Print Receipt | |||
|                         </div> | |||
|                     </div> | |||
| 
 | |||
|                 </section> | |||
|                 <section class="full-content"> | |||
|                     <div class='window'> | |||
|                         <section class='subwindow collapsed'> | |||
|                             <div class='subwindow-container collapsed'> | |||
|                                 <div class='subwindow-container-fix order-details-contents'> | |||
|                                 </div> | |||
|                             </div> | |||
|                         </section> | |||
|                         <section class='subwindow'> | |||
|                             <div class='subwindow-container'> | |||
|                                 <div class='subwindow-container-fix touch-scrollable scrollable-y'> | |||
|                                     <table class='client-list'> | |||
|                                         <thead> | |||
|                                             <tr> | |||
|                                                 <th>Reciept Ref.</th> | |||
|                                                 <th>Partner</th> | |||
|                                                 <th>Session</th> | |||
|                                                 <th>Amount Total</th> | |||
|                                             </tr> | |||
|                                         </thead> | |||
|                                         <tbody class='order-list-contents'> | |||
|                                         </tbody> | |||
|                                     </table> | |||
|                                 </div> | |||
|                             </div> | |||
|                         </section> | |||
|                     </div> | |||
|                 </section> | |||
|             </div> | |||
|         </div> | |||
|     </t> | |||
| 
 | |||
|     <t t-name="PosTicketOld"> | |||
|         <div class="pos-sale-ticket" style="margin-left:30% !important;"> | |||
| 
 | |||
|             <div class="pos-center-align"><t t-esc="moment().format('L LT')"/> <t t-esc="order.pos_reference"/></div> | |||
|             <br /> | |||
|             <t t-esc="widget.pos.company.name"/><br /> | |||
|             Phone: <t t-esc="widget.pos.company.phone || ''"/><br /> | |||
|             User: <t t-esc="widget.pos.cashier ? widget.pos.cashier.name : widget.pos.user.name"/><br /> | |||
|             <br /> | |||
| 
 | |||
|             <table class='receipt-orderlines'> | |||
|                 <colgroup> | |||
|                     <col width='50%' /> | |||
|                     <col width='25%' /> | |||
|                     <col width='25%' /> | |||
|                 </colgroup> | |||
|                 <tr t-foreach="orderlines" t-as="orderline"> | |||
|                     <td> | |||
|                         <t t-esc="orderline.product_id"/> | |||
|                          <t t-if="orderline.discount > 0"> | |||
|                             <div class="pos-disc-font"> | |||
|                                 With a <t t-esc="orderline.discount"/>% discount | |||
|                             </div> | |||
|                         </t> | |||
|                     </td> | |||
|                     <td class="pos-right-align"> | |||
|                         <t t-esc="orderline.qty"/> | |||
|                     </td> | |||
|                     <td class="pos-right-align"> | |||
|                         <t t-esc="widget.format_currency(orderline.price_unit)"/> | |||
|                     </td> | |||
|                 </tr> | |||
|             </table> | |||
|             <br /> | |||
|             <table class='receipt-total'> | |||
|                 <tr> | |||
|                     <td>Subtotal:</td> | |||
|                     <td class="pos-right-align"> | |||
|                         <t t-esc="widget.format_currency(order.amount_total-order.amount_tax)"/> | |||
|                     </td> | |||
|                 </tr> | |||
|                 <tr> | |||
|                     <td>Tax:</td> | |||
|                     <td class="pos-right-align"> | |||
|                         <t t-esc="widget.format_currency(order.amount_tax)" /> | |||
|                     </td> | |||
|                 </tr> | |||
|                 <tr> | |||
|                     <td>Discount:</td> | |||
|                     <td class="pos-right-align"> | |||
|                         <t t-esc="widget.format_currency(discount_total)"/> | |||
|                     </td> | |||
|                 </tr> | |||
|                 <tr class="emph"> | |||
|                     <td>Total:</td> | |||
|                     <td class="pos-right-align"> | |||
|                         <t t-esc="widget.format_currency(order.amount_total)"/> | |||
|                     </td> | |||
|                 </tr> | |||
|             </table> | |||
|             <br /> | |||
|             <table class='receipt-paymentlines'> | |||
|                 <t t-foreach="paymentlines" t-as="line"> | |||
|                   <tr> | |||
|                       <td> | |||
|                           <t t-esc="line.name"/> | |||
|                       </td> | |||
|                       <td class="pos-right-align"> | |||
|                           <t t-esc="widget.format_currency(line.amount)"/> | |||
|                       </td> | |||
|                   </tr> | |||
|                 </t> | |||
|             </table> | |||
|             <br /> | |||
|             <table class='receipt-change'> | |||
|                 <tr><td>Change:</td><td class="pos-right-align"> | |||
|                     <t t-esc="widget.format_currency(change)"/> | |||
|                     </td></tr> | |||
|             </table> | |||
|         </div> | |||
|     </t> | |||
| 
 | |||
| </templates> | |||
| @ -0,0 +1,27 @@ | |||
| <?xml version="1.0" encoding="utf-8"?> | |||
| <odoo> | |||
|     <report | |||
|             id="pos_orders" | |||
|             model="pos.order" | |||
|             string="Receipts" | |||
|             report_type="qweb-html" | |||
|             name="order_reprinting_pos.receipt_report" | |||
|             file="order_reprinting_pos.receipt_report" | |||
|         /> | |||
|     <record id="pos_receipt_report" model="ir.actions.report.xml"> | |||
|         <field name="name">Receipt</field> | |||
|         <field name="model">pos.order</field> | |||
|         <field name="report_type">qweb-pdf</field> | |||
|         <field name="report_name">point_of_sale.report_receipts</field> | |||
|     </record> | |||
|             <record id="view_pos_order_form_inherit" model="ir.ui.view"> | |||
|             <field name="name">view_pos_order_updated</field> | |||
|             <field name="model">pos.order</field> | |||
|             <field name="inherit_id" ref="point_of_sale.view_pos_order_tree"/> | |||
|             <field name="arch" type="xml"> | |||
|                 <xpath expr="//field[@name='partner_id']" position="after"> | |||
|                     <field name="currency_id" /> | |||
|                 </xpath> | |||
| 			  </field> | |||
| 		</record> | |||
| </odoo> | |||
| @ -0,0 +1,14 @@ | |||
| <?xml version="1.0" encoding="utf-8"?> | |||
| <odoo> | |||
|     <data> | |||
|         <template id="assets" inherit_id="point_of_sale.assets"> | |||
|             <xpath expr="." position="inside"> | |||
|                 <script type="text/javascript" src="/order_reprinting_pos/static/src/js/order_reprint.js"></script> | |||
|             </xpath> | |||
|             <xpath expr="//link[@id='pos-stylesheet']" position="after"> | |||
|               <link rel="stylesheet" href="/order_reprinting_pos/static/src/css/style.css"/> | |||
|             </xpath> | |||
|         </template> | |||
| 
 | |||
|     </data> | |||
| </odoo> | |||