openerp-community-reviewer team mailing list archive
-
openerp-community-reviewer team
-
Mailing list archive
-
Message #07796
[Merge] lp:~sylvain-legal/openerp-pos/7.0_pos_backup_draft_orders into lp:openerp-pos
Sylvain LE GAL (GRAP) has proposed merging lp:~sylvain-legal/openerp-pos/7.0_pos_backup_draft_orders into lp:openerp-pos with lp:~sylvain-legal/openerp-pos/7.0_pos_second_header as a prerequisite.
Commit message:
[ADD] Add new module to backup a draft order in Front End Point Of Sale
Requested reviews:
OpenERP Community Reviewer/Maintainer (openerp-community-reviewer)
For more details, see:
https://code.launchpad.net/~sylvain-legal/openerp-pos/7.0_pos_backup_draft_orders/+merge/228829
Add a new module to allow users to backup (save in database) draft pos order.
So, in the Point of Sale module, add a button "backup draft Order".
This can be usefull because some features are not available in Front End Point of sale for the time being. (Invoicing for exemple, or changing pricelist).
For security reasons it can be used, if the user has to shutdown his computer or to restart his browser.
Note:
- Flake8: OK;
--
https://code.launchpad.net/~sylvain-legal/openerp-pos/7.0_pos_backup_draft_orders/+merge/228829
Your team OpenERP Community Reviewer/Maintainer is requested to review the proposed merge of lp:~sylvain-legal/openerp-pos/7.0_pos_backup_draft_orders into lp:openerp-pos.
=== added directory 'pos_backup_draft_orders'
=== added file 'pos_backup_draft_orders/__init__.py'
--- pos_backup_draft_orders/__init__.py 1970-01-01 00:00:00 +0000
+++ pos_backup_draft_orders/__init__.py 2014-07-30 11:36:54 +0000
@@ -0,0 +1,24 @@
+# -*- encoding: utf-8 -*-
+##############################################################################
+#
+# Point Of Sale - Backup Draft Orders module for OpenERP
+# Copyright (C) 2013-2014 GRAP (http://www.grap.coop)
+# @author Julien WESTE
+# @author Sylvain LE GAL (https://twitter.com/legalsylvain)
+#
+# 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 <http://www.gnu.org/licenses/>.
+#
+##############################################################################
+
+import model
=== added file 'pos_backup_draft_orders/__openerp__.py'
--- pos_backup_draft_orders/__openerp__.py 1970-01-01 00:00:00 +0000
+++ pos_backup_draft_orders/__openerp__.py 2014-07-30 11:36:54 +0000
@@ -0,0 +1,58 @@
+# -*- encoding: utf-8 -*-
+##############################################################################
+#
+# Point Of Sale - Backup Draft Orders module for OpenERP
+# Copyright (C) 2014 GRAP (http://www.grap.coop)
+# @author Julien WESTE
+# @author Sylvain LE GAL (https://twitter.com/legalsylvain)
+#
+# 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 <http://www.gnu.org/licenses/>.
+#
+##############################################################################
+
+{
+ 'name': 'Point Of Sale - Backup Draft Orders',
+ 'summary': """Allow users to backup draft orders"""
+ """in Point Of Sale (Front end)""",
+ 'version': '0.1',
+ 'category': 'sale',
+ 'description': """
+Allow users to backup draft orders in Point Of Sale (Front end)
+===============================================================
+
+Functionality:
+--------------
+ * Allow user to backup in the backoffice side orders tiped in front-end;
+
+Copyright, Authors and Licence:
+-------------------------------
+ * Copyright: 2014, GRAP: Groupement Régional Alimentaire de Proximité;
+ * Author:
+ * Julien WESTE;
+ * Sylvain LE GAL (https://twitter.com/legalsylvain);
+ * Licence: AGPL-3 (http://www.gnu.org/licenses/);""",
+ 'author': 'GRAP',
+ 'website': 'http://www.grap.coop',
+ 'license': 'AGPL-3',
+ 'depends': [
+ 'point_of_sale',
+ 'pos_second_header',
+ ],
+ 'js': [
+ 'static/src/js/pbdo.js',
+ ],
+ 'css': [
+ 'static/src/css/pbdo.css',
+ ],
+}
=== added directory 'pos_backup_draft_orders/i18n'
=== added file 'pos_backup_draft_orders/i18n/fr.po'
--- pos_backup_draft_orders/i18n/fr.po 1970-01-01 00:00:00 +0000
+++ pos_backup_draft_orders/i18n/fr.po 2014-07-30 11:36:54 +0000
@@ -0,0 +1,45 @@
+# -*- encoding: utf-8 -*-
+##############################################################################
+#
+# Point Of Sale - Backup Draft Orders module for OpenERP
+# Copyright (C) 2013-2014 GRAP (http://www.grap.coop)
+# @author Julien WESTE
+# @author Sylvain LE GAL (https://twitter.com/legalsylvain)
+#
+# 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 <http://www.gnu.org/licenses/>.
+#
+##############################################################################
+# Translation of OpenERP Server.
+# This file contains the translation of the following modules:
+# * pos_backup_draft_orders
+#
+msgid ""
+msgstr ""
+"Project-Id-Version: OpenERP Server 7.0\n"
+"Report-Msgid-Bugs-To: \n"
+"POT-Creation-Date: 2014-04-16 17:38+0000\n"
+"PO-Revision-Date: 2014-04-16 17:38+0000\n"
+"Last-Translator: <>\n"
+"Language-Team: \n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=UTF-8\n"
+"Content-Transfer-Encoding: \n"
+"Plural-Forms: \n"
+
+#. module: pos_backup_draft_orders
+#. openerp-web
+#: code:addons/pos_backup_draft_orders/static/src/js/pbdo.js:50
+#, python-format
+msgid "Keep in Draft"
+msgstr "Sauvegarder"
=== added directory 'pos_backup_draft_orders/model'
=== added file 'pos_backup_draft_orders/model/__init__.py'
--- pos_backup_draft_orders/model/__init__.py 1970-01-01 00:00:00 +0000
+++ pos_backup_draft_orders/model/__init__.py 2014-07-30 11:36:54 +0000
@@ -0,0 +1,23 @@
+# -*- encoding: utf-8 -*-
+##############################################################################
+#
+# Point Of Sale - Backup Draft Orders module for OpenERP
+# Copyright (C) 2013-2014 GRAP (http://www.grap.coop)
+# @author Sylvain LE GAL (https://twitter.com/legalsylvain)
+#
+# 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 <http://www.gnu.org/licenses/>.
+#
+##############################################################################
+
+import pos_order
=== added file 'pos_backup_draft_orders/model/pos_order.py'
--- pos_backup_draft_orders/model/pos_order.py 1970-01-01 00:00:00 +0000
+++ pos_backup_draft_orders/model/pos_order.py 2014-07-30 11:36:54 +0000
@@ -0,0 +1,73 @@
+# -*- encoding: utf-8 -*-
+##############################################################################
+#
+# Point Of Sale - Backup Draft Orders module for OpenERP
+# Copyright (C) 2013-2014 GRAP (http://www.grap.coop)
+# @author Sylvain LE GAL (https://twitter.com/legalsylvain)
+#
+# 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 <http://www.gnu.org/licenses/>.
+#
+##############################################################################
+
+from openerp.osv.orm import Model
+
+
+class pos_order(Model):
+ _inherit = 'pos.order'
+
+ # custom function
+ def _create_draft_from_ui(self, cr, uid, orders, context=None):
+ order_ids = []
+ for tmp_order in orders:
+ order = tmp_order['data']
+ order_id = self.create(cr, uid, {
+ 'name': order['name'],
+ 'user_id': order['user_id'] or False,
+ 'session_id': order['pos_session_id'],
+ 'lines': order['lines'],
+ 'pos_reference': order['name'],
+ 'partner_id': order.get('partner_id', False)
+ }, context)
+ for payments in order['statement_ids']:
+ payment = payments[2]
+ self.add_payment(cr, uid, order_id, {
+ 'amount': payment['amount'] or 0.0,
+ 'payment_date': payment['name'],
+ 'statement_id': payment['statement_id'],
+ 'payment_name': payment.get('note', False),
+ 'journal': payment['journal_id']
+ }, context=context)
+ order_ids.append(order_id)
+ return order_ids
+
+ # Overload section
+ def create_from_ui(self, cr, uid, orders, context=None):
+ """
+ - remove from the 'orders' list all orders where amount_return is < 0
+ (because that means they are not paid, but just saved) and put them
+ in a 'saved_orders' list
+ - call a specific function for the 'saved_orders' list
+ - call the parent create_from_ui() for the remaining orders"""
+ saved_orders = []
+ for tmp_order in orders:
+ if tmp_order['data']['amount_return'] < 0\
+ and abs(tmp_order['data']['amount_return']) > 0.000001:
+ saved_orders.append(tmp_order)
+ orders.remove(tmp_order)
+
+ self._create_draft_from_ui(
+ cr, uid, saved_orders, context=context)
+
+ return super(pos_order, self).create_from_ui(
+ cr, uid, orders, context=context)
=== added directory 'pos_backup_draft_orders/static'
=== added directory 'pos_backup_draft_orders/static/src'
=== added directory 'pos_backup_draft_orders/static/src/img'
=== added file 'pos_backup_draft_orders/static/src/img/icon.png'
Binary files pos_backup_draft_orders/static/src/img/icon.png 1970-01-01 00:00:00 +0000 and pos_backup_draft_orders/static/src/img/icon.png 2014-07-30 11:36:54 +0000 differ
=== added directory 'pos_backup_draft_orders/static/src/js'
=== added file 'pos_backup_draft_orders/static/src/js/pbdo.js'
--- pos_backup_draft_orders/static/src/js/pbdo.js 1970-01-01 00:00:00 +0000
+++ pos_backup_draft_orders/static/src/js/pbdo.js 2014-07-30 11:36:54 +0000
@@ -0,0 +1,81 @@
+/******************************************************************************
+ Point Of Sale - Backup Draft Orders module for OpenERP
+ Copyright (C) 2014 GRAP (http://www.grap.coop)
+ @author Julien WESTE
+ @author Sylvain LE GAL (https://twitter.com/legalsylvain)
+
+ 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 <http://www.gnu.org/licenses/>.
+******************************************************************************/
+
+openerp.pos_backup_draft_orders = function (instance) {
+ module = instance.point_of_sale;
+ _t = instance.web._t;
+
+ /*************************************************************************
+ Overload : PosWidget to include button in PosOrderHeaderWidget widget
+ to backup draft orders
+ */
+ module.PosWidget = module.PosWidget.extend({
+
+ displayBackupButton: function(){
+ if (this.backup_order_button){
+ var order = this.pos.get('selectedOrder');
+ if (((order.get('orderLines').length + order.get('paymentLines').length) > 0) &&
+ (order.getChange()<0 && (Math.abs(order.getChange()) > 0.000001))){
+ this.backup_order_button.$el.fadeIn();
+ }
+ else{
+ this.backup_order_button.$el.fadeOut();
+ }
+ }
+ },
+
+ build_widgets: function(){
+ this._super();
+ var self = this;
+
+ // Create a button to backup the current order
+ this.backup_order_button = new module.HeaderButtonWidget(this,{
+ label:_t('Keep in Draft'),
+ action: function(){ self.backup_order(); },
+ });
+ this.backup_order_button.appendTo(this.$('#pos_order_header'));
+ this.pos.bind('change:selectedOrder', this.displayBackupButton, this);
+ this.backup_order_button.$el.fadeOut();
+ },
+
+ backup_order: function() {
+ var order = this.pos.get('selectedOrder');
+ this.pos.push_order(order.exportAsJSON());
+ this.pos.get('selectedOrder').destroy();
+ },
+
+ });
+
+ module.OrderWidget = module.OrderWidget.extend({
+ renderElement: function(){
+ this.pos_widget.displayBackupButton();
+ this._super();
+ },
+ });
+
+ module.PaymentScreenWidget = module.PaymentScreenWidget.extend({
+ updatePaymentSummary: function(){
+ this.pos_widget.displayBackupButton();
+ this._super();
+ },
+ });
+
+};
+
Follow ups