Browse Source
Merge branch '8.0_pos_require_customer' of https://github.com/apertoso/pos into apertoso-8.0_pos_require_customer
pull/80/head
Merge branch '8.0_pos_require_customer' of https://github.com/apertoso/pos into apertoso-8.0_pos_require_customer
pull/80/head
Pedro M. Baeza
9 years ago
12 changed files with 422 additions and 0 deletions
-
73pos_require_customer/README.rst
-
2pos_require_customer/__init__.py
-
55pos_require_customer/__openerp__.py
-
72pos_require_customer/i18n/nl_NL.po
-
62pos_require_customer/i18n/pos_require_customer.pot
-
2pos_require_customer/models/__init__.py
-
45pos_require_customer/models/pos.py
-
26pos_require_customer/static/src/js/pos_require_customer.js
-
12pos_require_customer/static/src/xml/templates.xml
-
1pos_require_customer/tests/__init__.py
-
38pos_require_customer/tests/test_pos.py
-
34pos_require_customer/views/pos_view.xml
@ -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 <https://github.com/OCA/{project_repo}/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 <https://github.com/OCA/{project_repo}/issues/new?body=module:%20{module_name}%0Aversion:%20{version}%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_. |
|||
|
|||
|
|||
Credits |
|||
======= |
|||
|
|||
Contributors |
|||
------------ |
|||
|
|||
* Jos De Graeve <Jos.DeGraeve@apertoso.be> |
|||
* Pedro M. Baeza <pedro.baeza@gmail.com> ( 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. |
@ -0,0 +1,2 @@ |
|||
# -*- coding: utf-8 -*- |
|||
from . import models |
@ -0,0 +1,55 @@ |
|||
# -*- coding: utf-8 -*- |
|||
############################################################################## |
|||
# |
|||
# Copyright (C) 2004-2014 Apertoso NV (<http://www.apertoso.be>). |
|||
# |
|||
# 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 <http://www.gnu.org/licenses/>. |
|||
# |
|||
############################################################################## |
|||
|
|||
{ |
|||
'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: |
@ -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." |
@ -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 "" |
|||
|
@ -0,0 +1,2 @@ |
|||
# -*- coding: utf-8 -*- |
|||
from . import pos |
@ -0,0 +1,45 @@ |
|||
# -*- coding: utf-8 -*- |
|||
############################################################################## |
|||
# |
|||
# Copyright (C) 2004-2014 Apertoso NV (<http://www.apertoso.be>). |
|||
# |
|||
# 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 <http://www.gnu.org/licenses/>. |
|||
# |
|||
############################################################################## |
|||
|
|||
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')) |
@ -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); |
|||
} |
|||
}); |
|||
|
|||
}; |
@ -0,0 +1,12 @@ |
|||
<?xml version="1.0" encoding="utf-8"?> |
|||
<openerp> |
|||
<data> |
|||
|
|||
<template id="assets_frontend" inherit_id="web.assets_common"> |
|||
<xpath expr="." position="inside"> |
|||
<script type="text/javascript" |
|||
src="/pos_require_customer/static/src/js/pos_require_customer.js"/> |
|||
</xpath> |
|||
</template> |
|||
</data> |
|||
</openerp> |
@ -0,0 +1 @@ |
|||
from . import test_pos |
@ -0,0 +1,38 @@ |
|||
# -*- coding: utf-8 -*- |
|||
|
|||
import openerp.tests.common as common |
|||
from openerp import exceptions |
|||
|
|||
|
|||
class TestPosRequireCustomer(common.TransactionCase): |
|||
def setUp(self): |
|||
super(TestPosRequireCustomer, self).setUp() |
|||
|
|||
def test_customer_not_required(self): |
|||
posconfig = self.env.ref('point_of_sale.pos_config_main') |
|||
posconfig.require_customer = False |
|||
|
|||
# Now Create new session and create a |
|||
# pos order in this session |
|||
pos_session = self.env['pos.session'].create( |
|||
{'config_id': posconfig.id}) |
|||
# should not raise any exception |
|||
self.env['pos.order'].create({ |
|||
'session_id': pos_session.id, |
|||
'partner_id': False, |
|||
}) |
|||
|
|||
def test_customer_is_required(self): |
|||
posconfig = self.env.ref('point_of_sale.pos_config_main') |
|||
posconfig.require_customer = True |
|||
|
|||
# Now Create new session and create a |
|||
# pos order in this session |
|||
pos_session = self.env['pos.session'].create( |
|||
{'config_id': posconfig.id}) |
|||
# should raise exceptions.ValidationError |
|||
with self.assertRaises(exceptions.ValidationError): |
|||
self.env['pos.order'].create({ |
|||
'session_id': pos_session.id, |
|||
'partner_id': False, |
|||
}) |
@ -0,0 +1,34 @@ |
|||
<?xml version="1.0"?> |
|||
<openerp> |
|||
<data> |
|||
|
|||
<record model="ir.ui.view" id="view_pos_config_form"> |
|||
<field name="name">pos.config.form.view</field> |
|||
<field name="model">pos.config</field> |
|||
<field name="inherit_id" |
|||
ref="point_of_sale.view_pos_config_form" /> |
|||
<field name="arch" type="xml"> |
|||
<xpath expr="//group[@string='Receipt']" position="after"> |
|||
<group string="Customer" col="4" > |
|||
<field name='require_customer' /> |
|||
</group> |
|||
</xpath> |
|||
</field> |
|||
</record> |
|||
|
|||
<record model="ir.ui.view" id="view_pos_pos_form_inherit"> |
|||
<field name="name">pos.order</field> |
|||
<field name="model">pos.order</field> |
|||
<field name="inherit_id" ref="point_of_sale.view_pos_pos_form"/> |
|||
<field name="arch" type="xml"> |
|||
<xpath expr="//sheet" position="inside"> |
|||
<field name="require_customer" invisible="1"/> |
|||
</xpath> |
|||
<xpath expr="//field[@name='partner_id']" position="attributes"> |
|||
<attribute name="attrs">{'readonly': [('state','=','invoiced')], 'required': [('require_customer','=',True)]}</attribute> |
|||
</xpath> |
|||
</field> |
|||
</record> |
|||
|
|||
</data> |
|||
</openerp> |
Write
Preview
Loading…
Cancel
Save
Reference in new issue