Browse Source

Merge pull request #1 from naglis/feature-wp4394

partner_credit_limit_pos: initial implementation
pull/176/head
Andrius Preimantas 9 years ago
parent
commit
db50aa9038
  1. 3
      partner_credit_limit_pos/AUTHORS
  2. 22
      partner_credit_limit_pos/COPYRIGHT
  3. 4
      partner_credit_limit_pos/README.rst
  4. 3
      partner_credit_limit_pos/__init__.py
  5. 19
      partner_credit_limit_pos/__openerp__.py
  6. 37
      partner_credit_limit_pos/static/src/js/main.js
  7. 12
      partner_credit_limit_pos/views/templates.xml

3
partner_credit_limit_pos/AUTHORS

@ -0,0 +1,3 @@
Authors ordered by first contribution.
Naglis Jonaitis <naglis@hbee.eu>

22
partner_credit_limit_pos/COPYRIGHT

@ -0,0 +1,22 @@
##############################################################################
#
# Odoo, Open Source Management Solution
# Copyright (C) 2016 by Versada <http://versada.lt/>
# 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 <http://www.gnu.org/licenses/>.
#
##############################################################################

4
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.

3
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.

19
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,
}

37
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);
}
},
});
};

12
partner_credit_limit_pos/views/templates.xml

@ -0,0 +1,12 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<template id="pos_assets_backend" name="POS Assets" inherit_id="point_of_sale.assets_backend">
<xpath expr="." position="inside">
<script type="text/javascript" src="/partner_credit_limit_pos/static/src/js/main.js"></script>
</xpath>
</template>
</data>
</openerp>
Loading…
Cancel
Save