diff --git a/pos_require_customer/README.rst b/pos_require_customer/README.rst new file mode 100644 index 00000000..ed97408f --- /dev/null +++ b/pos_require_customer/README.rst @@ -0,0 +1,73 @@ +.. image:: https://img.shields.io/badge/licence-AGPL--3-blue.svg + :alt: License: AGPL-3 + +Module name +=========== + +This module was written to extend the functionality of odoo pos +and 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. + + +Installation +============ + +This module depends on the `point_of_sale` Odoo official module. + +Configuration +============= + +To configure this module, you need to: + +* go to point of sale -> configuration -> point of sales +* select the point of sales you want configure +* If you want to require the partner for orders in this pos, select the + checkbox + +Usage +===== + +If a customer is not selected, the pos ui will display an error message. +In the backend the customer field is required when needed. + +For further information, please visit: + +* https://www.odoo.com/forum/help-1 + +Bug Tracker +=========== + +Bugs are tracked on `GitHub Issues `_. +In case of trouble, please check there if your issue has already been reported. +If you spotted it first, help us smashing it by providing a detailed and welcomed feedback +`here `_. + + +Credits +======= + +Contributors +------------ + +* Jos De Graeve +* Pedro M. Baeza ( reviews & feedback ) +* Sylvain LE GAL - https://github.com/legalsylvain ( reviews & feedback ) + +Maintainer +---------- + +.. image:: https://odoo-community.org/logo.png + :alt: Odoo Community Association + :target: https://odoo-community.org + +This module is maintained by the OCA. + +OCA, or the Odoo Community Association, is a nonprofit organization whose +mission is to support the collaborative development of Odoo features and +promote its widespread use. + +To contribute to this module, please visit http://odoo-community.org. diff --git a/pos_require_customer/__init__.py b/pos_require_customer/__init__.py new file mode 100644 index 00000000..a0fdc10f --- /dev/null +++ b/pos_require_customer/__init__.py @@ -0,0 +1,2 @@ +# -*- coding: utf-8 -*- +from . import models diff --git a/pos_require_customer/__openerp__.py b/pos_require_customer/__openerp__.py new file mode 100644 index 00000000..5daae511 --- /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, Odoo Community Association (OCA)', + 'images': [], + 'depends': ['point_of_sale'], + 'data': [ + 'static/src/xml/templates.xml', + 'views/pos_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..c5b5ab1a --- /dev/null +++ b/pos_require_customer/i18n/nl_NL.po @@ -0,0 +1,72 @@ +# 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 15:04+0100\n" +"PO-Revision-Date: 2015-06-02 15:04+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 +#: code:addons/pos_require_customer/pos.py:45 +#, python-format +msgid "Customer is required for this order and is missing" +msgstr "Klant is vereist voor deze order en ontbreekt" + +#. 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 +#: model:ir.model,name:pos_require_customer.model_pos_order +msgid "Point of Sale" +msgstr "Kassa" + +#. 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." + +#. module: pos_require_customer +#: view:pos.order:pos_require_customer.view_pos_pos_form_inherit +msgid "" +"{'readonly': [('state','=','invoiced')], 'required': " +"[('require_customer','=',True)]}" +msgstr "" + +#~ 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..ef64f016 --- /dev/null +++ b/pos_require_customer/i18n/pos_require_customer.pot @@ -0,0 +1,62 @@ +# 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 13:03+0000\n" +"PO-Revision-Date: 2015-06-02 13:03+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 +#: code:addons/pos_require_customer/pos.py:45 +#, python-format +msgid "Customer is required for this order and is missing" +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 +#: model:ir.model,name:pos_require_customer.model_pos_order +msgid "Point of Sale" +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 "" + +#. module: pos_require_customer +#: view:pos.order:pos_require_customer.view_pos_pos_form_inherit +msgid "{'readonly': [('state','=','invoiced')], 'required': [('require_customer','=',True)]}" +msgstr "" + diff --git a/pos_require_customer/models/__init__.py b/pos_require_customer/models/__init__.py new file mode 100644 index 00000000..36cbfda2 --- /dev/null +++ b/pos_require_customer/models/__init__.py @@ -0,0 +1,2 @@ +# -*- coding: utf-8 -*- +from . import pos diff --git a/pos_require_customer/models/pos.py b/pos_require_customer/models/pos.py new file mode 100644 index 00000000..138ae4b7 --- /dev/null +++ b/pos_require_customer/models/pos.py @@ -0,0 +1,45 @@ +# -*- 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 . +# +############################################################################## + +from openerp import fields, models, exceptions, api +from openerp.tools.translate import _ + + +class PosConfig(models.Model): + _inherit = 'pos.config' + + require_customer = fields.Boolean( + string='Require customer', + help='Require customer for orders in this point of sale') + + +class PosOrder(models.Model): + _inherit = 'pos.order' + + require_customer = fields.Boolean( + string='Require customer', + related='session_id.config_id.require_customer', readonly=True) + + @api.one + @api.constrains('partner_id', 'require_customer') + def _check_partner(self): + if self.require_customer and not self.partner_id: + raise exceptions.ValidationError( + _('Customer is required for this order and is missing')) 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 @@ + + + + +