diff --git a/account_limit/README.rst b/account_limit/README.rst new file mode 100644 index 000000000..2e2b5bb00 --- /dev/null +++ b/account_limit/README.rst @@ -0,0 +1,20 @@ +======================== +Account Credit Limit v10 +======================== +Account credit limit is a handy plugin for Odoo Accounting module to set a Credit limit for each Account. +The module will bring new fields total Credit, Debit and Balance in ‘Accounts tree view’ and ‘Account form view’. +The module also produce a warning message while making journal entries which will exceed the credit limit. +The features can simplify the credit evaluation +process of accounts like Customers accounts, Overdraft accounts, Bank accounts etc. + +Features +======== +* Know Total Debit of an account. +* Know Total Credit of an account. +* Know Balance of the account. +* Set the Credit limit for accounts. +* Stop an account exceeding the credit limit. + +Credits +======= +Nikhil Krishnan @ cybrosys, nikhil@cybrosys.in \ No newline at end of file diff --git a/account_limit/__init__.py b/account_limit/__init__.py new file mode 100644 index 000000000..a341bab17 --- /dev/null +++ b/account_limit/__init__.py @@ -0,0 +1,25 @@ +# -*- coding: utf-8 -*- + +############################################################################## +# +# Cybrosys Technologies Pvt. Ltd. +# Copyright (C) 2017-TODAY Cybrosys Technologies(). +# Author: Nikhil krishnan(nikhil@cybrosys.in) +# you can modify it under the terms of the GNU LESSER +# GENERAL PUBLIC LICENSE (LGPL v3), Version 3. +# +# It is forbidden to publish, distribute, sublicense, or sell copies +# of the Software or modified copies of the Software. +# +# 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 LESSER GENERAL PUBLIC LICENSE (LGPL v3) for more details. +# +# You should have received a copy of the GNU LESSER GENERAL PUBLIC LICENSE +# GENERAL PUBLIC LICENSE (LGPL v3) along with this program. +# If not, see . +# +############################################################################## + +import models diff --git a/account_limit/__manifest__.py b/account_limit/__manifest__.py new file mode 100644 index 000000000..5c2a440b2 --- /dev/null +++ b/account_limit/__manifest__.py @@ -0,0 +1,45 @@ +# -*- coding: utf-8 -*- +# +############################################################################## +# +# Cybrosys Technologies Pvt. Ltd. +# Copyright (C) 2017-TODAY Cybrosys Technologies(). +# Author: Nikhil krishnan() +# you can modify it under the terms of the GNU LESSER +# GENERAL PUBLIC LICENSE (LGPL v3), Version 3. +# +# It is forbidden to publish, distribute, sublicense, or sell copies +# of the Software or modified copies of the Software. +# +# 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 LESSER GENERAL PUBLIC LICENSE (LGPL v3) for more details. +# +# You should have received a copy of the GNU LESSER GENERAL PUBLIC LICENSE +# GENERAL PUBLIC LICENSE (LGPL v3) along with this program. +# If not, see . +# +############################################################################## + +{ + 'name': 'Account Credit Limit', + 'version': '10.0.1.0', + 'summary': """Generate warning message when credit limit of an account is exceed.""", + 'description': """Account credit limit is a handy plugin for Odoo Accounting module to set a Credit limit + for each Account. The module will bring new fields total Credit, Debit and Balance in ‘Accounts tree view’ and + ‘Account form view’. The module also produce a warning message while making journal entries which will exceed + the credit limit. The features can simplify the credit evaluation process of accounts like Customers accounts, + Overdraft accounts, Bank accounts etc.""", + 'author': 'Cybrosys Techno Solutions', + 'company': 'Cybrosys Techno Solutions', + 'website': 'https://www.cybrosys.com', + 'category': 'Accounting', + 'depends': ['account', 'account_accountant'], + 'license': 'LGPL-3', + 'data': ['views/account_credit_limit_view.xml'], + 'demo': [], + 'images': ['static/description/banner.jpg'], + 'installable': True, + 'auto_install': False, +} diff --git a/account_limit/models/__init__.py b/account_limit/models/__init__.py new file mode 100644 index 000000000..f7876db2e --- /dev/null +++ b/account_limit/models/__init__.py @@ -0,0 +1 @@ +import account diff --git a/account_limit/models/account.py b/account_limit/models/account.py new file mode 100644 index 000000000..2a852f036 --- /dev/null +++ b/account_limit/models/account.py @@ -0,0 +1,114 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# Cybrosys Technologies Pvt. Ltd. +# Copyright (C) 2017-TODAY Cybrosys Technologies(). +# Author: Nikhil krishnan() +# you can modify it under the terms of the GNU LESSER +# GENERAL PUBLIC LICENSE (LGPL v3), Version 3. +# +# It is forbidden to publish, distribute, sublicense, or sell copies +# of the Software or modified copies of the Software. +# +# 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 LESSER GENERAL PUBLIC LICENSE (LGPL v3) for more details. +# +# You should have received a copy of the GNU LESSER GENERAL PUBLIC LICENSE +# GENERAL PUBLIC LICENSE (LGPL v3) along with this program. +# If not, see . +# +############################################################################## + +from odoo import fields, api, _, models +from odoo.exceptions import Warning + + +class AccountAccount(models.Model): + _inherit = 'account.account' + + @api.depends('credit', 'debit', 'balance') + @api.multi + def get_credit_debit_balance(self): + print "get_credit_debit_balance", self + for obj in self: + credit = 0 + debit = 0 + account_lines = self.env['account.move.line'].search([('account_id', '=', obj.id)]) + for line in account_lines: + credit += line.credit + debit += line.debit + obj.credit = credit + obj.debit = debit + obj.balance = debit - credit + + credit = fields.Float(string='Credit', compute='get_credit_debit_balance') + debit = fields.Float(string='Debit', compute='get_credit_debit_balance') + balance = fields.Float(string='Balance', compute='get_credit_debit_balance') + account_credit_limit = fields.Float(string='Credit Limit', Help="Credit Limit for this particular Account.") + + +class AccountMove(models.Model): + _inherit = "account.move" + + @api.model + def create(self, vals): + credit = 0 + debit = 0 + if "line_ids" in vals.keys(): + for line in vals['line_ids']: + if line[2]['credit']: + account = self.env['account.account'].browse(line[2]['account_id']) + account_lines = self.env['account.move.line'].search([('account_id', '=', account.id)]) + for lines in account_lines: + credit += lines.credit + debit += lines.debit + if account.account_credit_limit: + if (credit+line[2]['credit'] - debit) > account.account_credit_limit: + raise Warning(_('Limit will Exceed .! \n Making this transaction will exceed the limit ' + 'defined for " %s " account') % account.name) + result = super(AccountMove, self).create(vals) + return result + + @api.multi + def write(self, vals): + if "line_ids" in vals.keys(): + for line in vals['line_ids']: + account_lines = self.env['account.move.line'].browse(line[1]) + if line[2]: + if 'account_id' in line[2]: + if line[2]['account_id']: + account = self.env['account.account'].browse(line[2]['account_id']) + if account.account_credit_limit: + if 'debit' in line[2]: + new_debit = line[2]['debit'] + else: + new_debit = account_lines.debit + if 'credit' in line[2]: + new_credit = line[2]['credit'] + else: + new_credit = account_lines.credit + if (account.credit + new_credit - new_debit - account.debit) > account.account_credit_limit: + raise Warning( + _('Limit will Exceed .! \n Making this transaction will exceed the limit ' + 'defined for " %s " account') % account.name) + else: + account = account_lines.account_id + if account.account_credit_limit: + if 'debit' in line[2]: + if line[2]['debit']: + old_debit = account_lines.debit + if (account.credit - line[2]['debit'] - account.debit + old_debit) > account.account_credit_limit: + raise Warning( + _('Limit will Exceed .! \n Making this transaction will exceed the limit ' + 'defined for " %s " account') % account.name) + if 'credit' in line[2]: + if line[2]['credit']: + old_credit = account_lines.credit + if (account.credit+line[2]['credit']-account.debit-old_credit) > account.account_credit_limit: + raise Warning( + _('Limit will Exceed .! \n Making this transaction will exceed the limit ' + 'defined for " %s " account') % account.name) + result = super(AccountMove, self).write(vals) + return result diff --git a/account_limit/static/description/Cash.png b/account_limit/static/description/Cash.png new file mode 100644 index 000000000..15aaade81 Binary files /dev/null and b/account_limit/static/description/Cash.png differ diff --git a/account_limit/static/description/Tree view account.png b/account_limit/static/description/Tree view account.png new file mode 100644 index 000000000..f4c6328c2 Binary files /dev/null and b/account_limit/static/description/Tree view account.png differ diff --git a/account_limit/static/description/Warning.png b/account_limit/static/description/Warning.png new file mode 100644 index 000000000..df259aca4 Binary files /dev/null and b/account_limit/static/description/Warning.png differ diff --git a/account_limit/static/description/banner.jpg b/account_limit/static/description/banner.jpg new file mode 100644 index 000000000..cce2d71e6 Binary files /dev/null and b/account_limit/static/description/banner.jpg differ diff --git a/account_limit/static/description/cybro_logo.png b/account_limit/static/description/cybro_logo.png new file mode 100644 index 000000000..bb309114c Binary files /dev/null and b/account_limit/static/description/cybro_logo.png differ diff --git a/account_limit/static/description/icon.png b/account_limit/static/description/icon.png new file mode 100644 index 000000000..49d3388fa Binary files /dev/null and b/account_limit/static/description/icon.png differ diff --git a/account_limit/static/description/index.html b/account_limit/static/description/index.html new file mode 100644 index 000000000..81857563b --- /dev/null +++ b/account_limit/static/description/index.html @@ -0,0 +1,105 @@ +
+
+
+

Account Credit Limit

+

Get total credit, total debit, balance of each account.

+

Set credit limits for accounts.

+

Cybrosys Technologies

+
+
+

Major Features:

+
    +
  •    Know Total Debit of an account.
  • +
  •    Know Total Credit of an account.
  • +
  •    Know Balance of the account.
  • +
  •    Set the Credit limit for accounts.
  • +
  •    Stop an account exceeding the credit limit.
  • +
+
+
+
+ +
+
+
+

Overview

+

Account credit limit is a handy plugin for Odoo Accounting module to set a Credit limit for each Account. The module will bring new fields total Credit, Debit and Balance in ‘Accounts tree view’ and ‘Account form view’. The module also produce a warning message while making journal entries which will exceed the credit limit. + The features can simplify the credit evaluation process of accounts like Customers accounts, Overdraft accounts, Bank accounts etc.

+
+
+
+ +
+
+
+

Account List/Tree view

+

+

Install the module and open chart of Accounts.

+

+
+ +
+
+
+

+

You can see that a new tree view is created here which lists Debit, Credit, and Balance of the respective accounts.

+

+
+
+
+ +
+
+
+

Account Form view

+
+ +
+
+
+

+

The fields i.e. Debit, Credit, and Balance will be displayed in individual account form also. + From here you can set the credit limit for the individual account.

+

+
+
+
+
+
+
+

Warning

+

+

The app will pop up a warning message while you make a journal entry which exceeds the credit limit.

+

+
+ +
+
+
+
+ +
+

Need Any Help?

+ +
diff --git a/account_limit/views/account_credit_limit_view.xml b/account_limit/views/account_credit_limit_view.xml new file mode 100644 index 000000000..43b8836a8 --- /dev/null +++ b/account_limit/views/account_credit_limit_view.xml @@ -0,0 +1,31 @@ + + + + + account.account.form + account.account + + + + + + + + + + + + + account.account.list + account.account + + + + + + + + + + +