diff --git a/partner_credit_limit_pos/AUTHORS b/partner_credit_limit_pos/AUTHORS new file mode 100644 index 000000000..9d9e125ff --- /dev/null +++ b/partner_credit_limit_pos/AUTHORS @@ -0,0 +1,3 @@ +Authors ordered by first contribution. + +Naglis Jonaitis diff --git a/partner_credit_limit_pos/COPYRIGHT b/partner_credit_limit_pos/COPYRIGHT new file mode 100644 index 000000000..4c4ae047f --- /dev/null +++ b/partner_credit_limit_pos/COPYRIGHT @@ -0,0 +1,22 @@ +############################################################################## +# +# Odoo, Open Source Management Solution +# Copyright (C) 2016 by Versada +# and contributors. See AUTHORS for more details. +# +# All Rights Reserved. +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU 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 General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . +# +############################################################################## diff --git a/partner_credit_limit_pos/README.rst b/partner_credit_limit_pos/README.rst new file mode 100644 index 000000000..b0beb843f --- /dev/null +++ b/partner_credit_limit_pos/README.rst @@ -0,0 +1,4 @@ +**Partner Credit Limit POS** + +When validating an order with a customer set in POS, this module module checks +if partner credit limit is not reached before allowing to validate the order. diff --git a/partner_credit_limit_pos/__init__.py b/partner_credit_limit_pos/__init__.py new file mode 100644 index 000000000..d5a63408b --- /dev/null +++ b/partner_credit_limit_pos/__init__.py @@ -0,0 +1,3 @@ +# -*- coding: utf-8 -*- +# This file is part of Odoo. The COPYRIGHT file at the top level of +# this module contains the full copyright notices and license terms. diff --git a/partner_credit_limit_pos/__openerp__.py b/partner_credit_limit_pos/__openerp__.py new file mode 100644 index 000000000..bd9b003cb --- /dev/null +++ b/partner_credit_limit_pos/__openerp__.py @@ -0,0 +1,19 @@ +# -*- coding: utf-8 -*- +# This file is part of Odoo. The COPYRIGHT file at the top level of +# this module contains the full copyright notices and license terms. +{ + 'name': 'Partner Credit Limit POS', + 'version': '0.1.0', + 'author': 'Versada', + 'category': 'Point of Sale', + 'website': 'http://versada.lt/', + 'licence': 'AGPL-3', + 'summary': 'Check partner credit limit in POS.', + 'depends': [ + 'point_of_sale', + 'partner_credit_limit', + ], + 'data': ['views/templates.xml'], + 'installable': True, + 'application': False, +} diff --git a/partner_credit_limit_pos/static/src/js/main.js b/partner_credit_limit_pos/static/src/js/main.js new file mode 100644 index 000000000..3bab79ccd --- /dev/null +++ b/partner_credit_limit_pos/static/src/js/main.js @@ -0,0 +1,37 @@ +openerp.partner_credit_limit_pos = function(instance) { + _t = instance.web._t; + instance.point_of_sale.PaymentScreenWidget.include({ + validate_order: function(options) { + var self = this, + order = this.pos.get('selectedOrder'), + partner_id = order.get_client() ? order.get_client().id : false, + super_ = this._super, + args = arguments; + + // Only check if partner is set. + if (partner_id) { + var model = new instance.web.Model('res.partner'); + return model.call('credit_limit_reached', [[partner_id], order.getTotalTaxIncluded(), true]).then( + function(data) { + return super_.apply(self, args); + }).fail( + function(error, event) { + if (error.code == 200) { + self.pos_widget.screen_selector.show_popup('error', { + message: _t('POS Order cannot be validated.'), + comment: error.data.message, + }); + } else { + self.pos_widget.screen_selector.show_popup('error', { + message: _t('Error: Could not check partner credit limit.'), + comment: _t('Your Internet connection is probably down.'), + }); + } + event.preventDefault(); + }); + } else { + return super_.apply(self, args); + } + }, + }); +}; diff --git a/partner_credit_limit_pos/views/templates.xml b/partner_credit_limit_pos/views/templates.xml new file mode 100644 index 000000000..62838d82e --- /dev/null +++ b/partner_credit_limit_pos/views/templates.xml @@ -0,0 +1,12 @@ + + + + + + + +