diff --git a/pos_order_load/__init__.py b/pos_order_load/__init__.py new file mode 100644 index 00000000..3aa4c8bb --- /dev/null +++ b/pos_order_load/__init__.py @@ -0,0 +1 @@ +import point_of_sale diff --git a/pos_order_load/__openerp__.py b/pos_order_load/__openerp__.py new file mode 100644 index 00000000..d3d2b6a2 --- /dev/null +++ b/pos_order_load/__openerp__.py @@ -0,0 +1,51 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# OpenERP, Open Source Management Solution +# Copyright (C) 2014-TODAY Akretion (). +# Copyright (C) 2014 Sylvain Calador (sylvain.calador@akretion.com). +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# 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 Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . +# +############################################################################## + +{ + 'name': 'POS Order Load', + 'version': '0.1', + 'author': 'Akretion', + 'category': 'Sales Management', + 'depends': [ + 'base', + 'decimal_precision', + 'point_of_sale', + 'product', + 'web', + ], + 'demo': [], + 'website': 'https://www.akretion.com', + 'description': """ + This module allows to load existing POS order + """, + 'data': [ + 'view/pos_order_load.xml', + ], + 'qweb': [ + 'static/src/xml/pos_order_load.xml', + ], + 'test': [], + 'installable': True, + 'auto_install': False, +} + +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/pos_order_load/point_of_sale.py b/pos_order_load/point_of_sale.py new file mode 100644 index 00000000..94d205d2 --- /dev/null +++ b/pos_order_load/point_of_sale.py @@ -0,0 +1,42 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# OpenERP, Open Source Management Solution +# Copyright (C) 2014 Akretion (). +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# 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 Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . +# +############################################################################## + +from openerp import models, api + + +class PosOrder(models.Model): + _inherit = 'pos.order' + + @api.model + def search_read_orders(self, query): + condition = [('pos_reference', 'ilike', query)] + fields = ['pos_reference', 'partner_id'] + return self.search_read(condition, fields, limit=10) + + @api.one + def load_order(self): + condition = [('order_id', '=', self.id)] + fields = ['product_id', 'price_unit', 'qty', 'discount'] + orderlines = self.lines.search_read(condition, fields) + return { + 'partner_id': self.partner_id and self.partner_id.id or False, + 'orderlines': orderlines + } diff --git a/pos_order_load/static/src/css/pos_order_load.css b/pos_order_load/static/src/css/pos_order_load.css new file mode 100644 index 00000000..cd00aca2 --- /dev/null +++ b/pos_order_load/static/src/css/pos_order_load.css @@ -0,0 +1,51 @@ +.screen .top-content .button.validate { + left: 0px; + margin-left: 150px; +} + +.pos .orderlist-screen .order-list{ + font-size: 16px; + width: 100%; + line-height: 40px; +} +.pos .orderlist-screen .order-list th, +.pos .orderlist-screen .order-list td { + padding: 0px 8px; +} +.pos .orderlist-screen .order-list tr{ + transition: all 150ms linear; + background: rgb(230,230,230); + cursor: pointer; +} +.pos .orderlist-screen .order-list thead > tr, +.pos .orderlist-screen .order-list tr:nth-child(even) { + background: rgb(247,247,247); +} +.pos .orderlist-screen .order-list tr.highlight{ + transition: all 150ms linear; + background: rgb(110,200,155) !important; + color: white; +} +.pos .orderlist-screen .order-list tr.lowlight{ + transition: all 150ms linear; + background: rgb(216, 238, 227); +} +.pos .orderlist-screen .order-list tr.lowlight:nth-child(even){ + transition: all 150ms linear; + background: rgb(227, 246, 237); +} +.pos .orderlist-screen .order-details{ + padding: 16px; + border-bottom: solid 5px rgb(110,200,155); +} + +.pos .orderlist-screen .searchbox{ + right: auto; + margin-left: -90px; + margin-top:8px; + left: 50%; +} +.pos .orderlist-screen .searchbox input{ + width: 120px; +} + diff --git a/pos_order_load/static/src/js/pos_order_load.js b/pos_order_load/static/src/js/pos_order_load.js new file mode 100644 index 00000000..48c3a99b --- /dev/null +++ b/pos_order_load/static/src/js/pos_order_load.js @@ -0,0 +1,238 @@ +/****************************************************************************** + * Point Of Sale - Product Template module for Odoo + * Copyright (C) 2014-Today Akretion (http://www.akretion.com) + * @author Sylvain Calador (sylvain.calador@akretion.com) + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * 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 Affero General Public License for more details. + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + *****************************************************************************/ + +openerp.pos_order_load = function(instance, local) { + module = instance.point_of_sale; + var QWeb = instance.web.qweb; + var _t = instance.web._t; + var round_pr = instance.web.round_precision; + + module.LoadButtonWidget = module.PosBaseWidget.extend({ + template: 'LoadButtonWidget', + init: function(parent, options){ + options = options || {}; + this._super(parent, options); + }, + start: function() { + var self = this; + this.$el.click(function(){ + var ss = self.pos.pos_widget.screen_selector; + ss.set_current_screen('orderlist'); + }); + }, + show: function(){ + this.$el.removeClass('oe_hidden'); + }, + hide: function(){ + this.$el.addClass('oe_hidden'); + } + }); + + module.PosWidget = module.PosWidget.extend({ + build_widgets: function() { + this._super(); + + this.orderlist_screen = new module.OrderListScreenWidget(this, {}); + this.orderlist_screen.appendTo(this.$('.screens')); + this.orderlist_screen.hide(); + + this.load_button = new module.LoadButtonWidget(this); + this.load_button.appendTo(this.$('li.orderline.empty')); + + this.screen_selector.screen_set['orderlist'] = + this.orderlist_screen; + }, + }); + + module.OrderWidget = module.OrderWidget.extend({ + renderElement: function(scrollbottom){ + this._super(scrollbottom); + if (this.pos_widget.load_button) { + this.pos_widget.load_button.appendTo( + this.pos_widget.$('li.orderline.empty') + ); + } + } + }); + + module.OrderListScreenWidget = module.ScreenWidget.extend({ + template: 'OrderListScreenWidget', + show_leftpane: true, + + init: function(parent, options){ + this._super(parent, options); + }, + + start: function() { + var self = this; + this._super(); + this.$el.find('span.button.back').click(function(){ + order = self.pos.get('selectedOrder'); + order.set_client(undefined); + order.get('orderLines').reset(); + self.pos_widget.order_widget.change_selected_order(); + var ss = self.pos.pos_widget.screen_selector; + + ss.set_current_screen('products'); + }); + this.$el.find('span.button.validate').click(function(){ + var ss = self.pos.pos_widget.screen_selector; + ss.set_current_screen('products'); + }); + + var search_timeout = null; + + this.$('.searchbox input').on('keyup',function(event){ + clearTimeout(search_timeout); + + var query = this.value; + + search_timeout = setTimeout(function(){ + self.perform_search(query); + },70); + + }); + + this.$('.searchbox .search-clear').click(function(){ + self.clear_search(); + }); + + }, + + // to override if necessary + add_product_attribute: function(product, key, orderline){ + return product; + }, + + load_order: function(order_id) { + var self = this; + var posOrderModel = new instance.web.Model('pos.order'); + return posOrderModel.call('load_order', [order_id]) + .then(function (result) { + var order = self.pos.get('selectedOrder'); + order.get('orderLines').reset(); + + var partner = self.pos.db.get_partner_by_id( + result[0].partner_id); + order.set_client(partner || undefined); + + var orderlines = result[0].orderlines || []; + for (var i=0, len=orderlines.length; i + diff --git a/pos_order_load/view/pos_order_load.xml b/pos_order_load/view/pos_order_load.xml new file mode 100644 index 00000000..f4d0c506 --- /dev/null +++ b/pos_order_load/view/pos_order_load.xml @@ -0,0 +1,18 @@ + + + + + + + + +