From e459e98afec6960a7a3c5f35436ffe7589bc13da Mon Sep 17 00:00:00 2001 From: Jos De Graeve Date: Tue, 2 Jun 2015 15:23:17 +0200 Subject: [PATCH] Added functionality to check on backend side --- pos_require_customer/i18n/nl_NL.po | 22 +++++++++++++++++-- .../i18n/pos_require_customer.pot | 20 +++++++++++++++-- pos_require_customer/pos.py | 18 ++++++++++++++- pos_require_customer/pos_view.xml | 14 ++++++++++++ 4 files changed, 69 insertions(+), 5 deletions(-) diff --git a/pos_require_customer/i18n/nl_NL.po b/pos_require_customer/i18n/nl_NL.po index 48acb40c..c5b5ab1a 100644 --- a/pos_require_customer/i18n/nl_NL.po +++ b/pos_require_customer/i18n/nl_NL.po @@ -6,8 +6,8 @@ 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" +"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" @@ -29,6 +29,12 @@ msgstr "Een anoniem kassa order kan niet worden bevestigd" 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 @@ -40,6 +46,11 @@ 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" @@ -50,5 +61,12 @@ msgstr "Klant verplichten" 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 index f71c9993..ef64f016 100644 --- a/pos_require_customer/i18n/pos_require_customer.pot +++ b/pos_require_customer/i18n/pos_require_customer.pot @@ -6,8 +6,8 @@ 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" +"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" @@ -27,6 +27,12 @@ msgstr "" 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 @@ -34,6 +40,11 @@ msgstr "" 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" @@ -44,3 +55,8 @@ msgstr "" 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/pos.py b/pos_require_customer/pos.py index f8b31e6d..138ae4b7 100644 --- a/pos_require_customer/pos.py +++ b/pos_require_customer/pos.py @@ -18,7 +18,8 @@ # ############################################################################## -from openerp import fields, models +from openerp import fields, models, exceptions, api +from openerp.tools.translate import _ class PosConfig(models.Model): @@ -27,3 +28,18 @@ class PosConfig(models.Model): 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/pos_view.xml b/pos_require_customer/pos_view.xml index 1f0cece6..a0d8307d 100644 --- a/pos_require_customer/pos_view.xml +++ b/pos_require_customer/pos_view.xml @@ -16,5 +16,19 @@ + + pos.order + pos.order + + + + + + + {'readonly': [('state','=','invoiced')], 'required': [('require_customer','=',True)]} + + + +