From d73f32138f13c85c36926c509b562d3147c2b9ed Mon Sep 17 00:00:00 2001 From: Jos De Graeve Date: Tue, 2 Jun 2015 11:48:05 +0200 Subject: [PATCH 01/12] New module: Point of Sale Require Customer This module allows you to require a customer for each pos order. In the pos session configuration, you can choose to require the customer for pos orders. If a customer is not selected, the pos ui will display an error message. In the backend the customer field is required when needed. --- pos_require_customer/__init__.py | 2 + pos_require_customer/__openerp__.py | 55 +++++++++++++++++++ pos_require_customer/i18n/nl_NL.po | 54 ++++++++++++++++++ .../i18n/pos_require_customer.pot | 46 ++++++++++++++++ pos_require_customer/pos_require_customer.py | 35 ++++++++++++ .../pos_require_customer_view.xml | 20 +++++++ .../static/src/js/pos_require_customer.js | 26 +++++++++ .../static/src/xml/templates.xml | 12 ++++ 8 files changed, 250 insertions(+) create mode 100644 pos_require_customer/__init__.py create mode 100644 pos_require_customer/__openerp__.py create mode 100644 pos_require_customer/i18n/nl_NL.po create mode 100644 pos_require_customer/i18n/pos_require_customer.pot create mode 100644 pos_require_customer/pos_require_customer.py create mode 100644 pos_require_customer/pos_require_customer_view.xml create mode 100644 pos_require_customer/static/src/js/pos_require_customer.js create mode 100644 pos_require_customer/static/src/xml/templates.xml diff --git a/pos_require_customer/__init__.py b/pos_require_customer/__init__.py new file mode 100644 index 00000000..f076ffb4 --- /dev/null +++ b/pos_require_customer/__init__.py @@ -0,0 +1,2 @@ +__author__ = 'josdg' +import pos_require_customer diff --git a/pos_require_customer/__openerp__.py b/pos_require_customer/__openerp__.py new file mode 100644 index 00000000..56b36b65 --- /dev/null +++ b/pos_require_customer/__openerp__.py @@ -0,0 +1,55 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# Copyright (C) 2004-2014 Apertoso NV (). +# +# 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 Require Customer', + 'version': '1.0.1', + 'category': 'Point Of Sale', + 'sequence': 6, + 'summary': 'Point of Sale Require Customer', + 'description': """ +Require customer for pos +======================== + +This module allows you to require a customer for each pos order. In the +pos session configuration, you can choose to require the customer for pos +orders. + +If a customer is not selected, the pos ui will display an error message. +In the backend the customer field is required when needed. + + """, + 'author': 'Apertoso NV', + 'images': [ ], + 'depends': ['point_of_sale'], + 'data': [ + 'static/src/xml/templates.xml', + 'pos_require_customer_view.xml', + ], + 'demo': [ ], + 'test': [ ], + 'installable': True, + 'application': True, + 'qweb': [ ], + 'website': 'http://www.apertoso.be', + 'auto_install': False, +} + +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/pos_require_customer/i18n/nl_NL.po b/pos_require_customer/i18n/nl_NL.po new file mode 100644 index 00000000..48acb40c --- /dev/null +++ b/pos_require_customer/i18n/nl_NL.po @@ -0,0 +1,54 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * pos_require_customer +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 8.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2015-06-02 11:36+0100\n" +"PO-Revision-Date: 2015-06-02 11:36+0100\n" +"Last-Translator: <>\n" +"Language-Team: \n" +"Language: nl_NL\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Plural-Forms: nplurals=2; plural=(n != 1);\n" +"X-Generator: Poedit 1.8\n" + +#. module: pos_require_customer +#. openerp-web +#: code:addons/pos_require_customer/static/src/js/pos_require_customer.js:16 +#, python-format +msgid "An anonymous order cannot be confirmed" +msgstr "Een anoniem kassa order kan niet worden bevestigd" + +#. module: pos_require_customer +#: view:pos.config:pos_require_customer.view_pos_config_form +msgid "Customer" +msgstr "Klant" + +#. module: pos_require_customer +#. openerp-web +#: code:addons/pos_require_customer/static/src/js/pos_require_customer.js:17 +#, python-format +msgid "" +"Please select a client for this order. This can be done by clicking the " +"order tab" +msgstr "" +"Selecteer een klant voor dit order. Dit kan gedaan worden door te klikken op " +"de tab bestelling" + +#. module: pos_require_customer +#: field:pos.config,require_customer:0 +msgid "Require customer" +msgstr "Klant verplichten" + +#. module: pos_require_customer +#: help:pos.config,require_customer:0 +msgid "Require customer for orders in this point of sale" +msgstr "Klant verplichten voor kassa orders in deze kassa." + +#~ msgid "Require customer for pos orders in the frontend" +#~ msgstr "Klant verplichten voor kassa orders in deze kassa." diff --git a/pos_require_customer/i18n/pos_require_customer.pot b/pos_require_customer/i18n/pos_require_customer.pot new file mode 100644 index 00000000..f71c9993 --- /dev/null +++ b/pos_require_customer/i18n/pos_require_customer.pot @@ -0,0 +1,46 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * pos_require_customer +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 8.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2015-06-02 09:24+0000\n" +"PO-Revision-Date: 2015-06-02 09:24+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_require_customer +#. openerp-web +#: code:addons/pos_require_customer/static/src/js/pos_require_customer.js:16 +#, python-format +msgid "An anonymous order cannot be confirmed" +msgstr "" + +#. module: pos_require_customer +#: view:pos.config:pos_require_customer.view_pos_config_form +msgid "Customer" +msgstr "" + +#. module: pos_require_customer +#. openerp-web +#: code:addons/pos_require_customer/static/src/js/pos_require_customer.js:17 +#, python-format +msgid "Please select a client for this order. This can be done by clicking the order tab" +msgstr "" + +#. module: pos_require_customer +#: field:pos.config,require_customer:0 +msgid "Require customer" +msgstr "" + +#. module: pos_require_customer +#: help:pos.config,require_customer:0 +msgid "Require customer for orders in this point of sale" +msgstr "" + diff --git a/pos_require_customer/pos_require_customer.py b/pos_require_customer/pos_require_customer.py new file mode 100644 index 00000000..bf823754 --- /dev/null +++ b/pos_require_customer/pos_require_customer.py @@ -0,0 +1,35 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# OpenERP, Open Source Management Solution +# Copyright (C) 2004-2010 Tiny SPRL (). +# Copyright (C) 2004-2014 Apertoso NV (). +# +# 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 logging +from openerp import fields +from openerp.models import Model + +class pos_config(Model): + _inherit = 'pos.config' + + require_customer = fields.Boolean( + string='Require customer', + help='Require customer for orders in this point of sale') + + + diff --git a/pos_require_customer/pos_require_customer_view.xml b/pos_require_customer/pos_require_customer_view.xml new file mode 100644 index 00000000..1f0cece6 --- /dev/null +++ b/pos_require_customer/pos_require_customer_view.xml @@ -0,0 +1,20 @@ + + + + + + pos.config.form.view + pos.config + + + + + + + + + + + + diff --git a/pos_require_customer/static/src/js/pos_require_customer.js b/pos_require_customer/static/src/js/pos_require_customer.js new file mode 100644 index 00000000..fca34525 --- /dev/null +++ b/pos_require_customer/static/src/js/pos_require_customer.js @@ -0,0 +1,26 @@ +openerp.pos_require_customer = function(instance){ + + var QWeb = instance.web.qweb, + _t = instance.web._t; + var module = instance.point_of_sale; + + module.PaymentScreenWidget.include({ + validate_order: function(options) { + var self = this; + options = options || {}; + + var currentOrder = this.pos.get('selectedOrder'); + + if( this.pos.config.require_customer && !currentOrder.get_client()){ + self.pos_widget.screen_selector.show_popup('error',{ + message: _t('An anonymous order cannot be confirmed'), + comment: _t('Please select a client for this order. This can be done by clicking the order tab') + }); + return; + } + // else + return this._super(options); + } + }); + +}; diff --git a/pos_require_customer/static/src/xml/templates.xml b/pos_require_customer/static/src/xml/templates.xml new file mode 100644 index 00000000..74164340 --- /dev/null +++ b/pos_require_customer/static/src/xml/templates.xml @@ -0,0 +1,12 @@ + + + + +