diff --git a/order_reprinting_pos/README.rst b/order_reprinting_pos/README.rst new file mode 100644 index 000000000..a9d92bb40 --- /dev/null +++ b/order_reprinting_pos/README.rst @@ -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 + + diff --git a/order_reprinting_pos/__init__.py b/order_reprinting_pos/__init__.py new file mode 100644 index 000000000..de6ca1dd8 --- /dev/null +++ b/order_reprinting_pos/__init__.py @@ -0,0 +1,26 @@ +# -*- coding: utf-8 -*- + +############################################################################## +# +# Cybrosys Technologies Pvt. Ltd. +# Copyright (C) 2017-TODAY Cybrosys Technologies(). +# Author: LINTO C T() +# 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 . +# +############################################################################## + +import models +import report diff --git a/order_reprinting_pos/__manifest__.py b/order_reprinting_pos/__manifest__.py new file mode 100644 index 000000000..f5d5ec68a --- /dev/null +++ b/order_reprinting_pos/__manifest__.py @@ -0,0 +1,43 @@ +# -*- coding: utf-8 -*- + +############################################################################## +# +# Cybrosys Technologies Pvt. Ltd. +# Copyright (C) 2017-TODAY Cybrosys Technologies(). +# Author: LINTO C T() +# 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 . +# +############################################################################## +{ + '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, +} diff --git a/order_reprinting_pos/models/__init__.py b/order_reprinting_pos/models/__init__.py new file mode 100644 index 000000000..daeb55462 --- /dev/null +++ b/order_reprinting_pos/models/__init__.py @@ -0,0 +1,3 @@ +# -*- coding: utf-8 -*- + +import pos_orderline \ No newline at end of file diff --git a/order_reprinting_pos/models/pos_orderline.py b/order_reprinting_pos/models/pos_orderline.py new file mode 100644 index 000000000..8269f56a6 --- /dev/null +++ b/order_reprinting_pos/models/pos_orderline.py @@ -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] diff --git a/order_reprinting_pos/report/__init__.py b/order_reprinting_pos/report/__init__.py new file mode 100644 index 000000000..8f6cbd5f1 --- /dev/null +++ b/order_reprinting_pos/report/__init__.py @@ -0,0 +1,25 @@ +# -*- coding: utf-8 -*- + +############################################################################## +# +# Cybrosys Technologies Pvt. Ltd. +# Copyright (C) 2017-TODAY Cybrosys Technologies(). +# Author: LINTO C T() +# 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 . +# +############################################################################## + +import pos_invoice diff --git a/order_reprinting_pos/report/pos_invoice.py b/order_reprinting_pos/report/pos_invoice.py new file mode 100644 index 000000000..99c5c8c29 --- /dev/null +++ b/order_reprinting_pos/report/pos_invoice.py @@ -0,0 +1,34 @@ +# -*- coding: utf-8 -*- + +############################################################################## +# +# Cybrosys Technologies Pvt. Ltd. +# Copyright (C) 2017-TODAY Cybrosys Technologies(). +# Author: LINTO C T() +# 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 . +# +############################################################################## + +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)}) diff --git a/order_reprinting_pos/report/receipt_report.xml b/order_reprinting_pos/report/receipt_report.xml new file mode 100644 index 000000000..60c5efc6b --- /dev/null +++ b/order_reprinting_pos/report/receipt_report.xml @@ -0,0 +1,98 @@ + + + + + + + + diff --git a/order_reprinting_pos/static/description/banner.jpg b/order_reprinting_pos/static/description/banner.jpg new file mode 100644 index 000000000..ea5b7a990 Binary files /dev/null and b/order_reprinting_pos/static/description/banner.jpg differ diff --git a/order_reprinting_pos/static/description/cybro_logo.png b/order_reprinting_pos/static/description/cybro_logo.png new file mode 100644 index 000000000..bb309114c Binary files /dev/null and b/order_reprinting_pos/static/description/cybro_logo.png differ diff --git a/order_reprinting_pos/static/description/icon.png b/order_reprinting_pos/static/description/icon.png new file mode 100644 index 000000000..49e85922c Binary files /dev/null and b/order_reprinting_pos/static/description/icon.png differ diff --git a/order_reprinting_pos/static/description/index.html b/order_reprinting_pos/static/description/index.html new file mode 100644 index 000000000..3ccc409b6 --- /dev/null +++ b/order_reprinting_pos/static/description/index.html @@ -0,0 +1,92 @@ +
+
+

POS Old Orders

+

Order Reprinting POS

+

Cybrosys Technologies , www.cybrosys.com

+
+
+ +
+
+
+
+

+ 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. +

+
+ +
+
+
+ +
+
+
+
+
+
+ +
+
+

By clicking on the 'Orders' button, we can see all orders list.

+
+ +
+

+ 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. +

+
+
+
+
+ +
+
+
+
+
+
+ +
+

+ The 'Print Receipt' button can be used to download this order in a pdf file. +

+
+ +
+
+
+
+
+
+ +
+

Need Any Help?

+ +
diff --git a/order_reprinting_pos/static/description/old-receipt.png b/order_reprinting_pos/static/description/old-receipt.png new file mode 100644 index 000000000..7bcb25ddb Binary files /dev/null and b/order_reprinting_pos/static/description/old-receipt.png differ diff --git a/order_reprinting_pos/static/description/order-button.png b/order_reprinting_pos/static/description/order-button.png new file mode 100644 index 000000000..8ffe405cd Binary files /dev/null and b/order_reprinting_pos/static/description/order-button.png differ diff --git a/order_reprinting_pos/static/description/order-re-pdf.png b/order_reprinting_pos/static/description/order-re-pdf.png new file mode 100644 index 000000000..75636e0b2 Binary files /dev/null and b/order_reprinting_pos/static/description/order-re-pdf.png differ diff --git a/order_reprinting_pos/static/description/orders-list.png b/order_reprinting_pos/static/description/orders-list.png new file mode 100644 index 000000000..7d96e0ffd Binary files /dev/null and b/order_reprinting_pos/static/description/orders-list.png differ diff --git a/order_reprinting_pos/static/src/css/style.css b/order_reprinting_pos/static/src/css/style.css new file mode 100644 index 000000000..9f017f7e0 --- /dev/null +++ b/order_reprinting_pos/static/src/css/style.css @@ -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; +} \ No newline at end of file diff --git a/order_reprinting_pos/static/src/js/order_reprint.js b/order_reprinting_pos/static/src/js/order_reprint.js new file mode 100644 index 000000000..7603a68a8 --- /dev/null +++ b/order_reprinting_pos/static/src/js/order_reprint.js @@ -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}); + + +}); \ No newline at end of file diff --git a/order_reprinting_pos/static/src/xml/pos.xml b/order_reprinting_pos/static/src/xml/pos.xml new file mode 100644 index 000000000..2274f8cd1 --- /dev/null +++ b/order_reprinting_pos/static/src/xml/pos.xml @@ -0,0 +1,154 @@ + + + + +
+ + Orders + +
+
+
+ + + + + + + Print + + + +
+
+
+ + + Cancel + + + + + +
+ +
+ +
+
+
+ +
+
+
+ + + + + + + + + + + +
Reciept Ref.PartnerSessionAmount Total
+
+
+
+
+
+
+
+
+ + +
+ +
+
+
+ Phone:
+ User:
+
+ + + + + + + + + + + + +
+ + +
+ With a % discount +
+
+
+ + + +
+
+ + + + + + + + + + + + + + + + + +
Subtotal: + +
Tax: + +
Discount: + +
Total: + +
+
+ + + + + + + +
+ + + +
+
+ + +
Change: + +
+
+
+ +
\ No newline at end of file diff --git a/order_reprinting_pos/views/point_of_sale_report.xml b/order_reprinting_pos/views/point_of_sale_report.xml new file mode 100644 index 000000000..68fcb3933 --- /dev/null +++ b/order_reprinting_pos/views/point_of_sale_report.xml @@ -0,0 +1,27 @@ + + + + + Receipt + pos.order + qweb-pdf + point_of_sale.report_receipts + + + view_pos_order_updated + pos.order + + + + + + + + diff --git a/order_reprinting_pos/views/pos_template.xml b/order_reprinting_pos/views/pos_template.xml new file mode 100644 index 000000000..63ef28029 --- /dev/null +++ b/order_reprinting_pos/views/pos_template.xml @@ -0,0 +1,14 @@ + + + + + + +