diff --git a/pos_customer_required/README.rst b/pos_customer_required/README.rst deleted file mode 100644 index f25be82c..00000000 --- a/pos_customer_required/README.rst +++ /dev/null @@ -1,92 +0,0 @@ -.. image:: https://img.shields.io/badge/licence-AGPL--3-blue.svg - :target: http://www.gnu.org/licenses/agpl-3.0-standalone.html - :alt: License: AGPL-3 - - -================================= -Point Of Sale - Customer Required -================================= - -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. - -Two new options are available: - -* Customer 'Required before starting the order'; -* Customer 'Required before paying'; - -'Required before starting the order' Option -------------------------------------------- -In the frontend PoS, the default screen is the screen to select customers. - -* Users are not allowed to start selling before having selected a customer; -* Users can not 'deselect a customer', only select an other one; - -'Required before paying' Option -------------------------------- -In the frontend PoS, the user can start selling, but if the user tries to -make payment and if a customer is not selected, the pos ui will display an -error message. - - -.. image:: /pos_customer_required/static/description/frontend_pos_error_message.png - -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 -* search for the "Require Customer" and choose between the following values: - * 'Optional'; (this module has no effect on this PoS config) - * 'Required before paying'; - * 'Required before starting the order'; - -Usage -===== - - -.. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas - :alt: Try me on Runbot - :target: https://runbot.odoo-community.org/runbot/184/9.0 - -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. - - -Credits -======= - -Contributors ------------- - -* Jos De Graeve -* Sylvain LE GAL -* Pedro M. Baeza ( 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_customer_required/__init__.py b/pos_customer_required/__init__.py index a0fdc10f..0650744f 100644 --- a/pos_customer_required/__init__.py +++ b/pos_customer_required/__init__.py @@ -1,2 +1 @@ -# -*- coding: utf-8 -*- from . import models diff --git a/pos_customer_required/__openerp__.py b/pos_customer_required/__manifest__.py similarity index 84% rename from pos_customer_required/__openerp__.py rename to pos_customer_required/__manifest__.py index 08a4140c..6c9f5d4d 100644 --- a/pos_customer_required/__openerp__.py +++ b/pos_customer_required/__manifest__.py @@ -1,17 +1,18 @@ -# -*- coding: utf-8 -*- # Copyright (C) 2004-Today Apertoso NV () # Copyright (C) 2016-Today: La Louve () +# Copyright (C) 2019-Today: Druidoo () # @author: Jos DE GRAEVE () # @author: Sylvain LE GAL (https://twitter.com/legalsylvain) # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html { 'name': 'Point of Sale Require Customer', - 'version': '9.0.1.0.0', + 'version': '12.0.1.0.0', 'category': 'Point Of Sale', 'summary': 'Point of Sale Require Customer', 'author': 'Apertoso NV, La Louve, Odoo Community Association (OCA)', 'website': 'http://www.apertoso.be', + 'license': 'AGPL-3', 'depends': [ 'point_of_sale', ], @@ -21,7 +22,7 @@ 'views/pos_order_view.xml', ], 'demo': [ - 'demo/pos_config.yml', + 'demo/pos_config.xml', ], 'installable': True, } diff --git a/pos_customer_required/demo/pos_config.xml b/pos_customer_required/demo/pos_config.xml new file mode 100644 index 00000000..a61f6c6e --- /dev/null +++ b/pos_customer_required/demo/pos_config.xml @@ -0,0 +1,14 @@ + + + + + + + order + + diff --git a/pos_customer_required/demo/pos_config.yml b/pos_customer_required/demo/pos_config.yml deleted file mode 100644 index 370b5b57..00000000 --- a/pos_customer_required/demo/pos_config.yml +++ /dev/null @@ -1,7 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright (C) 2016-Today: La Louve () -# @author: Sylvain LE GAL (https://twitter.com/legalsylvain) -# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). - -- !record {model: pos.config, id: point_of_sale.pos_config_main}: - require_customer: order diff --git a/pos_customer_required/migrations/9.0.1.0.0/post-migration.py b/pos_customer_required/migrations/9.0.1.0.0/post-migration.py deleted file mode 100644 index 76208613..00000000 --- a/pos_customer_required/migrations/9.0.1.0.0/post-migration.py +++ /dev/null @@ -1,19 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright (C) 2016-Today: La Louve () -# @author: Sylvain LE GAL (https://twitter.com/legalsylvain) -# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). - -from openupgradelib import openupgrade - - -BOOLEAN_TO_SELECTION = [ - ('false', 'no'), - ('true', 'order'), -] - - -@openupgrade.migrate() -def migrate(cr, installed_version): - openupgrade.map_values( - cr, openupgrade.get_legacy_name('require_customer'), - 'require_customer', BOOLEAN_TO_SELECTION, table='pos_config') diff --git a/pos_customer_required/migrations/9.0.1.0.0/pre-migration.py b/pos_customer_required/migrations/9.0.1.0.0/pre-migration.py deleted file mode 100644 index 7932ef97..00000000 --- a/pos_customer_required/migrations/9.0.1.0.0/pre-migration.py +++ /dev/null @@ -1,18 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright (C) 2016-Today: La Louve () -# @author: Sylvain LE GAL (https://twitter.com/legalsylvain) -# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). - -from openupgradelib import openupgrade - - -column_renames = { - 'pos_config': [ - ('require_customer', None), - ] -} - - -@openupgrade.migrate() -def migrate(cr, version): - openupgrade.rename_columns(cr, column_renames) diff --git a/pos_customer_required/models/__init__.py b/pos_customer_required/models/__init__.py index 8dd7b1a7..4831032c 100644 --- a/pos_customer_required/models/__init__.py +++ b/pos_customer_required/models/__init__.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- from . import pos_config from . import pos_order from . import pos_make_payment diff --git a/pos_customer_required/models/pos_config.py b/pos_customer_required/models/pos_config.py index 38d6d30c..de799c01 100644 --- a/pos_customer_required/models/pos_config.py +++ b/pos_customer_required/models/pos_config.py @@ -1,11 +1,11 @@ -# -*- coding: utf-8 -*- # Copyright (C) 2004-Today Apertoso NV () # Copyright (C) 2016-Today: La Louve () +# Copyright (C) 2019-Today: Druidoo () # @author: Jos DE GRAEVE () # @author: Sylvain LE GAL (https://twitter.com/legalsylvain) # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). -from openerp import fields, models +from odoo import fields, models class PosConfig(models.Model): diff --git a/pos_customer_required/models/pos_make_payment.py b/pos_customer_required/models/pos_make_payment.py index 358b21d5..d7548b95 100644 --- a/pos_customer_required/models/pos_make_payment.py +++ b/pos_customer_required/models/pos_make_payment.py @@ -1,11 +1,11 @@ -# -*- coding: utf-8 -*- # Copyright (C) 2016-Today: La Louve () +# Copyright (C) 2019-Today: Druidoo () # @author: Sylvain LE GAL (https://twitter.com/legalsylvain) # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). -from openerp import models, api, _ -from openerp.exceptions import UserError +from odoo import models, api, _ +from odoo.exceptions import UserError class PosMakePayment(models.TransientModel): diff --git a/pos_customer_required/models/pos_order.py b/pos_customer_required/models/pos_order.py index d61f2efe..c17aad21 100644 --- a/pos_customer_required/models/pos_order.py +++ b/pos_customer_required/models/pos_order.py @@ -1,12 +1,11 @@ -# -*- coding: utf-8 -*- # Copyright (C) 2004-Today Apertoso NV () # Copyright (C) 2016-Today: La Louve () +# Copyright (C) 2019-Today: Druidoo () # @author: Jos DE GRAEVE () # @author: Sylvain LE GAL (https://twitter.com/legalsylvain) # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). -from openerp import fields, models, exceptions, api -from openerp.tools.translate import _ +from odoo import fields, models, exceptions, api, _ class PosOrder(models.Model): @@ -24,10 +23,12 @@ class PosOrder(models.Model): help="True if a customer is required to begin the order.\n" "See the PoS Config to change this setting") - @api.one @api.constrains('partner_id', 'require_customer') def _check_partner(self): - if (self.session_id.config_id.require_customer == 'order' and - not self.partner_id): - raise exceptions.ValidationError( - _('Customer is required for this order and is missing.')) + for rec in self: + if ( + rec.session_id.config_id.require_customer == 'order' and + not rec.partner_id + ): + raise exceptions.ValidationError(_( + 'Customer is required for this order and is missing.')) diff --git a/pos_customer_required/readme/CONFIGURE.rst b/pos_customer_required/readme/CONFIGURE.rst new file mode 100644 index 00000000..3754a786 --- /dev/null +++ b/pos_customer_required/readme/CONFIGURE.rst @@ -0,0 +1,8 @@ +To configure this module, you need to: + +* go to point of sale -> configuration -> point of sales +* select the point of sales you want configure +* search for the "Require Customer" and choose between the following values: + * 'Optional'; (this module has no effect on this PoS config) + * 'Required before paying'; + * 'Required before starting the order'; diff --git a/pos_customer_required/readme/CONTRIBUTORS.rst b/pos_customer_required/readme/CONTRIBUTORS.rst new file mode 100644 index 00000000..4a36e6ea --- /dev/null +++ b/pos_customer_required/readme/CONTRIBUTORS.rst @@ -0,0 +1,4 @@ +* Jos De Graeve +* Sylvain LE GAL +* Pedro M. Baeza ( reviews & feedback ) +* Druidoo diff --git a/pos_customer_required/readme/DESCRIPTION.rst b/pos_customer_required/readme/DESCRIPTION.rst new file mode 100644 index 00000000..4f28974a --- /dev/null +++ b/pos_customer_required/readme/DESCRIPTION.rst @@ -0,0 +1,28 @@ +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. + +Two new options are available: + +* Customer 'Required before starting the order'; +* Customer 'Required before paying'; + +'Required before starting the order' Option +------------------------------------------- +In the frontend PoS, the default screen is the screen to select customers. + +* Users are not allowed to start selling before having selected a customer; +* Users can not 'deselect a customer', only select an other one; + +'Required before paying' Option +------------------------------- +In the frontend PoS, the user can start selling, but if the user tries to +make payment and if a customer is not selected, the pos ui will display an +error message. + + +.. image:: /pos_customer_required/static/description/frontend_pos_error_message.png diff --git a/pos_customer_required/readme/USAGE.rst b/pos_customer_required/readme/USAGE.rst new file mode 100644 index 00000000..8471f7f9 --- /dev/null +++ b/pos_customer_required/readme/USAGE.rst @@ -0,0 +1,3 @@ +.. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas + :alt: Try me on Runbot + :target: https://runbot.odoo-community.org/runbot/184/9.0 diff --git a/pos_customer_required/static/src/js/pos_customer_required.js b/pos_customer_required/static/src/js/pos_customer_required.js index d873dec8..ff25b4a9 100644 --- a/pos_customer_required/static/src/js/pos_customer_required.js +++ b/pos_customer_required/static/src/js/pos_customer_required.js @@ -5,7 +5,7 @@ @author: Jos DE GRAEVE () @author: Sylvain LE GAL (https://twitter.com/legalsylvain) - The licence is in the file __openerp__.py + The licence is in the file __manifest__.py */ @@ -20,7 +20,7 @@ odoo.define('pos_customer_required.pos_customer_required', function (require) { screens.PaymentScreenWidget.include({ validate_order: function(options) { if(this.pos.config.require_customer != 'no' - && !this.pos.get('selectedOrder').get_client()){ + && !this.pos.get_order().get_client()){ this.gui.show_popup('error',{ 'title': _t('An anonymous order cannot be confirmed'), 'body': _t('Please select a customer for this order.'), @@ -45,7 +45,7 @@ odoo.define('pos_customer_required.pos_customer_required', function (require) { var _show_screen_ = gui.Gui.prototype.show_screen; gui.Gui.prototype.show_screen = function(screen_name, params, refresh){ if(this.pos.config.require_customer == 'order' - && !this.pos.get('selectedOrder').get_client() + && !this.pos.get_order().get_client() && screen_name != 'clientlist'){ // We call first the original screen, to avoid to break the // 'previous screen' mecanism diff --git a/pos_customer_required/static/src/xml/templates.xml b/pos_customer_required/static/src/xml/templates.xml index ef1769f6..9264a0b6 100644 --- a/pos_customer_required/static/src/xml/templates.xml +++ b/pos_customer_required/static/src/xml/templates.xml @@ -6,10 +6,10 @@ @author: Jos DE GRAEVE () @author: Sylvain LE GAL (https://twitter.com/legalsylvain) - The licence is in the file __openerp__.py + The licence is in the file __manifest__.py --> - + - + diff --git a/pos_customer_required/tests/__init__.py b/pos_customer_required/tests/__init__.py index fdfb07c3..abf4b32c 100644 --- a/pos_customer_required/tests/__init__.py +++ b/pos_customer_required/tests/__init__.py @@ -1,2 +1 @@ -# -*- coding: utf-8 -*- from . import test_pos diff --git a/pos_customer_required/tests/test_pos.py b/pos_customer_required/tests/test_pos.py index 31c36eb5..ead58f5e 100644 --- a/pos_customer_required/tests/test_pos.py +++ b/pos_customer_required/tests/test_pos.py @@ -1,38 +1,48 @@ -# -*- coding: utf-8 -*- -import openerp.tests.common as common -from openerp import exceptions +import odoo.tests.common as common +from odoo import exceptions class TestPosRequireCustomer(common.TransactionCase): def setUp(self): super(TestPosRequireCustomer, self).setUp() + self.pos_config = self.env.ref('point_of_sale.pos_config_main') def test_customer_not_required(self): - posconfig = self.env.ref('point_of_sale.pos_config_main') - posconfig.require_customer = 'no' + self.pos_config.require_customer = 'no' # Now Create new session and create a # pos order in this session - pos_session = self.env['pos.session'].create( - {'config_id': posconfig.id}) + pos_session = self.env['pos.session'].create({ + 'user_id': 1, + 'config_id': self.pos_config.id + }) # should not raise any exception self.env['pos.order'].create({ 'session_id': pos_session.id, 'partner_id': False, + 'amount_tax': 0.0, + 'amount_total': 0.0, + 'amount_paid': 0.0, + 'amount_return': 0.0 }) def test_customer_is_required(self): - posconfig = self.env.ref('point_of_sale.pos_config_main') - posconfig.require_customer = 'order' + self.pos_config.require_customer = 'order' # Now Create new session and create a # pos order in this session - pos_session = self.env['pos.session'].create( - {'config_id': posconfig.id}) + pos_session = self.env['pos.session'].create({ + 'user_id': 1, + 'config_id': self.pos_config.id + }) # should raise exceptions.ValidationError with self.assertRaises(exceptions.ValidationError): self.env['pos.order'].create({ 'session_id': pos_session.id, 'partner_id': False, + 'amount_tax': 0.0, + 'amount_total': 0.0, + 'amount_paid': 0.0, + 'amount_return': 0.0 }) diff --git a/pos_customer_required/views/pos_config_view.xml b/pos_customer_required/views/pos_config_view.xml index 0c22d6b7..35f6ee0f 100644 --- a/pos_customer_required/views/pos_config_view.xml +++ b/pos_customer_required/views/pos_config_view.xml @@ -6,18 +6,31 @@ @author: Jos DE GRAEVE () @author: Sylvain LE GAL (https://twitter.com/legalsylvain) - The licence is in the file __openerp__.py + The licence is in the file __manifest__.py --> + view.pos.config.form pos.config - + - - - +
+
+
+
+
+
diff --git a/pos_customer_required/views/pos_order_view.xml b/pos_customer_required/views/pos_order_view.xml index 5c7ea772..7cd4232a 100644 --- a/pos_customer_required/views/pos_order_view.xml +++ b/pos_customer_required/views/pos_order_view.xml @@ -6,12 +6,13 @@ @author: Jos DE GRAEVE () @author: Sylvain LE GAL (https://twitter.com/legalsylvain) - The licence is in the file __openerp__.py + The licence is in the file __manifest__.py --> + view.pos.order.form pos.order