From f111656f45dfba2f8488e3d233db855eac6e04d9 Mon Sep 17 00:00:00 2001 From: Sylvain LE GAL Date: Sat, 15 Nov 2014 18:45:30 +0100 Subject: [PATCH 1/8] [ADD] 7.0 'pos_backup_draft_orders' --- pos_backup_draft_orders/__init__.py | 24 ++++++ pos_backup_draft_orders/__openerp__.py | 58 +++++++++++++ pos_backup_draft_orders/i18n/fr.po | 45 ++++++++++ pos_backup_draft_orders/model/__init__.py | 23 +++++ pos_backup_draft_orders/model/pos_order.py | 73 ++++++++++++++++ .../static/src/img/icon.png | Bin 0 -> 3680 bytes pos_backup_draft_orders/static/src/js/pbdo.js | 81 ++++++++++++++++++ 7 files changed, 304 insertions(+) create mode 100644 pos_backup_draft_orders/__init__.py create mode 100644 pos_backup_draft_orders/__openerp__.py create mode 100644 pos_backup_draft_orders/i18n/fr.po create mode 100644 pos_backup_draft_orders/model/__init__.py create mode 100644 pos_backup_draft_orders/model/pos_order.py create mode 100644 pos_backup_draft_orders/static/src/img/icon.png create mode 100644 pos_backup_draft_orders/static/src/js/pbdo.js diff --git a/pos_backup_draft_orders/__init__.py b/pos_backup_draft_orders/__init__.py new file mode 100644 index 00000000..4a934418 --- /dev/null +++ b/pos_backup_draft_orders/__init__.py @@ -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 . +# +############################################################################## + +import model diff --git a/pos_backup_draft_orders/__openerp__.py b/pos_backup_draft_orders/__openerp__.py new file mode 100644 index 00000000..3a36747a --- /dev/null +++ b/pos_backup_draft_orders/__openerp__.py @@ -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 . +# +############################################################################## + +{ + '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', + ], +} diff --git a/pos_backup_draft_orders/i18n/fr.po b/pos_backup_draft_orders/i18n/fr.po new file mode 100644 index 00000000..1e0d3c7b --- /dev/null +++ b/pos_backup_draft_orders/i18n/fr.po @@ -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 . +# +############################################################################## +# 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" diff --git a/pos_backup_draft_orders/model/__init__.py b/pos_backup_draft_orders/model/__init__.py new file mode 100644 index 00000000..9b09b1d6 --- /dev/null +++ b/pos_backup_draft_orders/model/__init__.py @@ -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 . +# +############################################################################## + +import pos_order diff --git a/pos_backup_draft_orders/model/pos_order.py b/pos_backup_draft_orders/model/pos_order.py new file mode 100644 index 00000000..e980e43c --- /dev/null +++ b/pos_backup_draft_orders/model/pos_order.py @@ -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 . +# +############################################################################## + +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) diff --git a/pos_backup_draft_orders/static/src/img/icon.png b/pos_backup_draft_orders/static/src/img/icon.png new file mode 100644 index 0000000000000000000000000000000000000000..74ed9c99f64a11a04bd195417d91061d8011db08 GIT binary patch literal 3680 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. +******************************************************************************/ + +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(); + }, + }); + +}; + From 52d68dad1e404852d2e0e704baf2436fd107e84e Mon Sep 17 00:00:00 2001 From: Sylvain LE GAL Date: Sat, 15 Nov 2014 18:47:11 +0100 Subject: [PATCH 2/8] [REF] 7.0 'pos_backup_draft_orders' minor change in __openerp__ description --- pos_backup_draft_orders/__openerp__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pos_backup_draft_orders/__openerp__.py b/pos_backup_draft_orders/__openerp__.py index 3a36747a..ee5d27ec 100644 --- a/pos_backup_draft_orders/__openerp__.py +++ b/pos_backup_draft_orders/__openerp__.py @@ -26,7 +26,7 @@ 'summary': """Allow users to backup draft orders""" """in Point Of Sale (Front end)""", 'version': '0.1', - 'category': 'sale', + 'category': 'Point Of Sale', 'description': """ Allow users to backup draft orders in Point Of Sale (Front end) =============================================================== From b9fde05f7d171c9e1a7acbd9ac9be01dcda1a9cf Mon Sep 17 00:00:00 2001 From: Sylvain LE GAL Date: Sat, 15 Nov 2014 19:20:54 +0100 Subject: [PATCH 3/8] [FIX] 'pos_backup_draft_orders' Pylint --- pos_backup_draft_orders/__init__.py | 2 +- pos_backup_draft_orders/model/__init__.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/pos_backup_draft_orders/__init__.py b/pos_backup_draft_orders/__init__.py index 4a934418..d780e648 100644 --- a/pos_backup_draft_orders/__init__.py +++ b/pos_backup_draft_orders/__init__.py @@ -21,4 +21,4 @@ # ############################################################################## -import model +from . import model diff --git a/pos_backup_draft_orders/model/__init__.py b/pos_backup_draft_orders/model/__init__.py index 9b09b1d6..26e841dc 100644 --- a/pos_backup_draft_orders/model/__init__.py +++ b/pos_backup_draft_orders/model/__init__.py @@ -20,4 +20,4 @@ # ############################################################################## -import pos_order +from . import pos_order From 6361dc9cabbc4e811c852a1160ac244a8f2fef23 Mon Sep 17 00:00:00 2001 From: Sylvain LE GAL Date: Sat, 15 Nov 2014 21:05:37 +0100 Subject: [PATCH 4/8] [ADD] 'pos_backup_draft_orders' Tests --- pos_backup_draft_orders/tests/__init__.py | 28 +++++ .../tests/test_pos_backup_draft_orders.py | 113 ++++++++++++++++++ 2 files changed, 141 insertions(+) create mode 100644 pos_backup_draft_orders/tests/__init__.py create mode 100644 pos_backup_draft_orders/tests/test_pos_backup_draft_orders.py diff --git a/pos_backup_draft_orders/tests/__init__.py b/pos_backup_draft_orders/tests/__init__.py new file mode 100644 index 00000000..878868f8 --- /dev/null +++ b/pos_backup_draft_orders/tests/__init__.py @@ -0,0 +1,28 @@ +# -*- 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 . +# +############################################################################## + + +from . import test_pos_backup_draft_orders + +fast_suite = [ + test_pos_backup_draft_orders, +] diff --git a/pos_backup_draft_orders/tests/test_pos_backup_draft_orders.py b/pos_backup_draft_orders/tests/test_pos_backup_draft_orders.py new file mode 100644 index 00000000..fd48c202 --- /dev/null +++ b/pos_backup_draft_orders/tests/test_pos_backup_draft_orders.py @@ -0,0 +1,113 @@ +# -*- 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 . +# +############################################################################## + +# from openerp.osv import osv +from openerp.tests.common import TransactionCase + + +class TestPosBackupDraftOrders(TransactionCase): + """Tests for 'Point Of Sale - Backup Draft Orders' Module""" + + def setUp(self): + super(TestPosBackupDraftOrders, self).setUp() + cr, uid = self.cr, self.uid + self.imd_obj = self.registry('ir.model.data') + self.po_obj = self.registry('pos.order') + self.ps_obj = self.registry('pos.session') + self.abs_obj = self.registry('account.bank.statement') + self.session_id = self.ps_obj.search(cr, uid, [])[0] + self.evian_product_id = self.imd_obj.get_object_reference( + cr, uid, 'point_of_sale', 'evian_2l')[1] + self.cash_journal_id = self.imd_obj.get_object_reference( + cr, uid, 'account', 'cash_journal')[1] + self.statement_id = self.abs_obj.search(cr, uid, [ + ('journal_id', '=', self.cash_journal_id), + ('state', '=', 'open')])[0] + + # Test Section + def test_01_create_paid_order(self): + """[Non regression] Test if the behaviour when the POS order is""" + """paid works.""" + cr, uid = self.cr, self.uid + po_ids = self.po_obj.search(cr, uid, []) + data = [{'data': { + 'user_id': uid, + 'name': 'ORDER NAME TEST 01', + 'pos_session_id': self.session_id, + 'lines': [[0, 0, { + 'product_id': self.evian_product_id, + 'discount': 0, + 'price_unit': 1.26, + 'qty': 5}]], + 'statement_ids': [[0, 0, { + 'journal_id': self.cash_journal_id, + 'amount': 10, + 'name': '2015-01-01 00:00:00', + 'statement_id': self.statement_id, + }]], + 'amount_paid': 10, + 'amount_tax': 0, + 'amount_return': 3.7, + 'amount_total': 6.3}, + }] + self.po_obj.create_from_ui(cr, uid, data) + po = self.po_obj.browse( + cr, uid, self.po_obj.search( + cr, uid, [('id', 'not in', po_ids)])[0]) + self.assertEqual( + po.state, 'paid', + "Pay an Order In Front Office must create a paid" + " order in back office") + + def test_02_create_draft_order(self): + """[Feature] Test if the behaviour when the POS order is""" + """unpaid works.""" + cr, uid = self.cr, self.uid + po_ids = self.po_obj.search(cr, uid, []) + data = [{'data': { + 'user_id': uid, + 'name': 'ORDER NAME TEST 02', + 'pos_session_id': self.session_id, + 'lines': [[0, 0, { + 'product_id': self.evian_product_id, + 'discount': 0, + 'price_unit': 1.26, + 'qty': 5}]], + 'statement_ids': [[0, 0, { + 'journal_id': self.cash_journal_id, + 'amount': 2, + 'name': '2015-01-01 00:00:00', + 'statement_id': self.statement_id, + }]], + 'amount_paid': 2, + 'amount_tax': 0, + 'amount_return': -4.3, + 'amount_total': 6.3}, + }] + self.po_obj.create_from_ui(cr, uid, data) + po = self.po_obj.browse( + cr, uid, self.po_obj.search( + cr, uid, [('id', 'not in', po_ids)])[0]) + self.assertEqual( + po.state, 'draft', + "An unpaid or partial paid Order In Front Office must create a" + "draft order in back office.") From 338239e41aa7a3f8814aeb3f7f5f5b1b0fd99681 Mon Sep 17 00:00:00 2001 From: Sylvain LE GAL Date: Sat, 15 Nov 2014 21:13:20 +0100 Subject: [PATCH 5/8] [FIX] 'pos_backup_draft_orders' Pylint --- .../tests/test_pos_backup_draft_orders.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/pos_backup_draft_orders/tests/test_pos_backup_draft_orders.py b/pos_backup_draft_orders/tests/test_pos_backup_draft_orders.py index fd48c202..c6675eb3 100644 --- a/pos_backup_draft_orders/tests/test_pos_backup_draft_orders.py +++ b/pos_backup_draft_orders/tests/test_pos_backup_draft_orders.py @@ -45,8 +45,8 @@ class TestPosBackupDraftOrders(TransactionCase): # Test Section def test_01_create_paid_order(self): - """[Non regression] Test if the behaviour when the POS order is""" - """paid works.""" + """[Non regression] Test if the behaviour when the POS order is + paid works.""" cr, uid = self.cr, self.uid po_ids = self.po_obj.search(cr, uid, []) data = [{'data': { @@ -79,8 +79,8 @@ class TestPosBackupDraftOrders(TransactionCase): " order in back office") def test_02_create_draft_order(self): - """[Feature] Test if the behaviour when the POS order is""" - """unpaid works.""" + """[Feature] Test if the behaviour when the POS order is + unpaid works.""" cr, uid = self.cr, self.uid po_ids = self.po_obj.search(cr, uid, []) data = [{'data': { From c526e31de1a686e313bc28797da835d232578d17 Mon Sep 17 00:00:00 2001 From: Sylvain LE GAL Date: Sat, 15 Nov 2014 21:26:56 +0100 Subject: [PATCH 6/8] [FIX] 'pos_backup_draft_orders' Test was failing because pos session wasn't available; --- .../tests/test_pos_backup_draft_orders.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/pos_backup_draft_orders/tests/test_pos_backup_draft_orders.py b/pos_backup_draft_orders/tests/test_pos_backup_draft_orders.py index c6675eb3..2d335e57 100644 --- a/pos_backup_draft_orders/tests/test_pos_backup_draft_orders.py +++ b/pos_backup_draft_orders/tests/test_pos_backup_draft_orders.py @@ -34,7 +34,11 @@ class TestPosBackupDraftOrders(TransactionCase): self.po_obj = self.registry('pos.order') self.ps_obj = self.registry('pos.session') self.abs_obj = self.registry('account.bank.statement') - self.session_id = self.ps_obj.search(cr, uid, [])[0] + pc_id = self.imd_obj.get_object_reference( + cr, uid, 'point_of_sale', 'pos_config_main')[1] + self.session_id = self.ps_obj.create(cr, uid, { + 'config_id': pc_id, + }) self.evian_product_id = self.imd_obj.get_object_reference( cr, uid, 'point_of_sale', 'evian_2l')[1] self.cash_journal_id = self.imd_obj.get_object_reference( From 3cfffabfef401b267089bb7424c23281a02a368f Mon Sep 17 00:00:00 2001 From: Sylvain LE GAL Date: Sun, 16 Nov 2014 03:10:18 +0100 Subject: [PATCH 7/8] [FIX] Add pot file --- .../i18n/pos_backup_draft_orders.pot | 31 +++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 pos_backup_draft_orders/i18n/pos_backup_draft_orders.pot diff --git a/pos_backup_draft_orders/i18n/pos_backup_draft_orders.pot b/pos_backup_draft_orders/i18n/pos_backup_draft_orders.pot new file mode 100644 index 00000000..94771bcf --- /dev/null +++ b/pos_backup_draft_orders/i18n/pos_backup_draft_orders.pot @@ -0,0 +1,31 @@ +# 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-11-16 02:09+0000\n" +"PO-Revision-Date: 2014-11-16 02:09+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 "" + +#. module: pos_backup_draft_orders +#: code:_description:0 +#: model:ir.model,name:pos_backup_draft_orders.model_pos_order +#, python-format +msgid "Point of Sale" +msgstr "" + From 57cc56d8301df43be1e95de429e75c4f8da31d34 Mon Sep 17 00:00:00 2001 From: Sylvain LE GAL Date: Sun, 16 Nov 2014 03:33:46 +0100 Subject: [PATCH 8/8] [FIX] 'pos_backup_draft_orders' Incorrect description --- pos_backup_draft_orders/__openerp__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pos_backup_draft_orders/__openerp__.py b/pos_backup_draft_orders/__openerp__.py index ee5d27ec..a50e44a0 100644 --- a/pos_backup_draft_orders/__openerp__.py +++ b/pos_backup_draft_orders/__openerp__.py @@ -33,7 +33,7 @@ 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; + * Allow user to backup in the backoffice side orders selected in front-end; Copyright, Authors and Licence: -------------------------------