diff --git a/partner_credit_limit/README.rst b/partner_credit_limit/README.rst new file mode 100644 index 000000000..4c76161b0 --- /dev/null +++ b/partner_credit_limit/README.rst @@ -0,0 +1,76 @@ +.. image:: https://img.shields.io/badge/licence-AGPL--3-blue.svg + :target: http://www.gnu.org/licenses/agpl-3.0-standalone.html + :alt: License: AGPL-3 + +==================== +Partner Credit Limit +==================== + +Module by it's own does nothing - it is used as a base by other modules like: +* partner_credit_limit_account +* partner_credit_limit_sale +* partner_credit_limit_pos +* etc. + +These modules makes Credit Limit checks in respective modules (account, +sale, pos, etc.) + +Installation +============ + +To install this module, you need to: + +* Click on Install button + +Configuration +============= + +No additional configuration needed. + +Usage +===== + +To use this module, you need to: + +* additionally install other modules depending on this one + +For further information, please visit: + +* https://www.odoo.com/forum/help-1 + +Known issues / Roadmap +====================== + +* No bugs reported + +Bug Tracker +=========== + +Bugs are tracked on `GitHub 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 `_. + + +Credits +======= + +Contributors +------------ + +* Andrius Preimantas + +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. \ No newline at end of file diff --git a/partner_credit_limit/__init__.py b/partner_credit_limit/__init__.py new file mode 100644 index 000000000..ad75e0062 --- /dev/null +++ b/partner_credit_limit/__init__.py @@ -0,0 +1,23 @@ +# -*- encoding: utf-8 -*- +############################################################################## +# +# OpenERP, Open Source Management Solution +# This module copyright (C) 2015 UAB Versada +# (). +# +# 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 . +# +############################################################################## + +from . import model diff --git a/partner_credit_limit/__openerp__.py b/partner_credit_limit/__openerp__.py new file mode 100644 index 000000000..66859ba7e --- /dev/null +++ b/partner_credit_limit/__openerp__.py @@ -0,0 +1,36 @@ +# -*- encoding: utf-8 -*- +############################################################################## +# +# OpenERP, Open Source Management Solution +# This module copyright (C) 2015 UAB Versada +# (). +# +# 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 . +# +############################################################################## + +{ + 'name': 'Partner Credit Limit', + 'version': '0.1', + 'author': 'Versada UAB,Odoo Community Association (OCA)', + 'category': 'Hidden', + 'website': 'http://www.versada.lt', + 'depends': [ + 'base', + ], + 'data': [ + ], + 'installable': True, + 'application': False, +} diff --git a/partner_credit_limit/model/__init__.py b/partner_credit_limit/model/__init__.py new file mode 100644 index 000000000..07570ae65 --- /dev/null +++ b/partner_credit_limit/model/__init__.py @@ -0,0 +1,23 @@ +# -*- encoding: utf-8 -*- +############################################################################## +# +# OpenERP, Open Source Management Solution +# This module copyright (C) 2015 UAB Versada +# (). +# +# 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 . +# +############################################################################## + +from . import res diff --git a/partner_credit_limit/model/res.py b/partner_credit_limit/model/res.py new file mode 100644 index 000000000..b65d08ef4 --- /dev/null +++ b/partner_credit_limit/model/res.py @@ -0,0 +1,47 @@ +# -*- encoding: utf-8 -*- +############################################################################## +# +# OpenERP, Open Source Management Solution +# This module copyright (C) 2015 UAB Versada +# (). +# +# 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 . +# +############################################################################## + +from openerp import models, api +from openerp.exceptions import ValidationError + + +class ResPartner(models.Model): + _inherit = 'res.partner' + + @api.multi + def credit_limit_reached(self, credit_increase=0.0, raise_error=True): + """ + Returns True (or exception) if credit limit is reched othervise False + """ + for each in self: + # credit_limit is synchronized between company and contacts but + # credit is not + credit = each.parent_id and each.parent_id.credit or each.credit + credit_increased = credit + credit_increase + if each.credit_limit > 0 and credit_increased > each.credit_limit: + if raise_error: + raise ValidationError( + "Credit Limit exceeded for partner %s!\n\n" + "Credit Limit: %.2f\nExceeding Credit: %.2f\n" % ( + self.display_name, each.credit_limit, + credit_increased)) + return True diff --git a/partner_credit_limit_account/README.rst b/partner_credit_limit_account/README.rst new file mode 100644 index 000000000..ad60f68cf --- /dev/null +++ b/partner_credit_limit_account/README.rst @@ -0,0 +1,71 @@ +.. image:: https://img.shields.io/badge/licence-AGPL--3-blue.svg + :target: http://www.gnu.org/licenses/agpl-3.0-standalone.html + :alt: License: AGPL-3 + +============================ +Partner Credit Limit Account +============================ + +Check if Credit Limit is not exceeded on Partner when Account Move is validated +(e.g. on Customer Invoice confirmation) + +Installation +============ + +To install this module, you need to: + +* have partner_credit_limit in your addons path + +Configuration +============= + +No additional configuration needed. + +Usage +===== + +To use this module, you need to: + +* validate Account Move. If Credit limit is maxed after validation an exception + is thrown + +For further information, please visit: + +* https://www.odoo.com/forum/help-1 + +Known issues / Roadmap +====================== + +* No bugs reported + +Bug Tracker +=========== + +Bugs are tracked on `GitHub 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 `_. + + +Credits +======= + +Contributors +------------ + +* Andrius Preimantas + +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. \ No newline at end of file diff --git a/partner_credit_limit_account/__init__.py b/partner_credit_limit_account/__init__.py new file mode 100644 index 000000000..ad75e0062 --- /dev/null +++ b/partner_credit_limit_account/__init__.py @@ -0,0 +1,23 @@ +# -*- encoding: utf-8 -*- +############################################################################## +# +# OpenERP, Open Source Management Solution +# This module copyright (C) 2015 UAB Versada +# (). +# +# 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 . +# +############################################################################## + +from . import model diff --git a/partner_credit_limit_account/__openerp__.py b/partner_credit_limit_account/__openerp__.py new file mode 100644 index 000000000..0b8ed4c0a --- /dev/null +++ b/partner_credit_limit_account/__openerp__.py @@ -0,0 +1,37 @@ +# -*- encoding: utf-8 -*- +############################################################################## +# +# OpenERP, Open Source Management Solution +# This module copyright (C) 2015 UAB Versada +# (). +# +# 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 . +# +############################################################################## + +{ + 'name': 'Partner Credit Limit', + 'version': '0.1', + 'author': 'Versada UAB,Odoo Community Association (OCA)', + 'category': 'Account', + 'website': 'http://www.versada.lt', + 'depends': [ + 'partner_credit_limit', + 'account' + ], + 'data': [ + ], + 'installable': True, + 'application': False, +} diff --git a/partner_credit_limit_account/model/__init__.py b/partner_credit_limit_account/model/__init__.py new file mode 100644 index 000000000..ee23413a0 --- /dev/null +++ b/partner_credit_limit_account/model/__init__.py @@ -0,0 +1,23 @@ +# -*- encoding: utf-8 -*- +############################################################################## +# +# OpenERP, Open Source Management Solution +# This module copyright (C) 2015 UAB Versada +# (). +# +# 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 . +# +############################################################################## + +from . import account diff --git a/partner_credit_limit_account/model/account.py b/partner_credit_limit_account/model/account.py new file mode 100644 index 000000000..a1930d916 --- /dev/null +++ b/partner_credit_limit_account/model/account.py @@ -0,0 +1,36 @@ +# -*- encoding: utf-8 -*- +############################################################################## +# +# OpenERP, Open Source Management Solution +# This module copyright (C) 2015 UAB Versada +# (). +# +# 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 . +# +############################################################################## + +from openerp import models + + +class AccountMove(models.Model): + _inherit = 'account.move' + + def validate(self, cr, uid, ids, context=None): + to_ret = super(AccountMove, self).validate( + cr, uid, ids, context=context) + for each in self.browse(cr, uid, ids, context): + for line in each.line_id: + if line.partner_id: + line.partner_id.credit_limit_reached() + return to_ret diff --git a/partner_credit_limit_sale/README.rst b/partner_credit_limit_sale/README.rst new file mode 100644 index 000000000..38aa8e684 --- /dev/null +++ b/partner_credit_limit_sale/README.rst @@ -0,0 +1,71 @@ +.. image:: https://img.shields.io/badge/licence-AGPL--3-blue.svg + :target: http://www.gnu.org/licenses/agpl-3.0-standalone.html + :alt: License: AGPL-3 + +========================= +Partner Credit Limit Sale +========================= + +Check if Credit Limit would not be exceeded for a Partner after confirming +Sale Order + +Installation +============ + +To install this module, you need to: + +* have partner_credit_limit in your addons path + +Configuration +============= + +No additional configuration needed. + +Usage +===== + +To use this module, you need to: + +* validate Sale Order. If Order amount + current customer credit would be more + than Credit Limit an exception is thrown and Order could not be validated + +For further information, please visit: + +* https://www.odoo.com/forum/help-1 + +Known issues / Roadmap +====================== + +* No bugs reported + +Bug Tracker +=========== + +Bugs are tracked on `GitHub 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 `_. + + +Credits +======= + +Contributors +------------ + +* Andrius Preimantas + +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. \ No newline at end of file diff --git a/partner_credit_limit_sale/__init__.py b/partner_credit_limit_sale/__init__.py new file mode 100644 index 000000000..9c537d0ec --- /dev/null +++ b/partner_credit_limit_sale/__init__.py @@ -0,0 +1,21 @@ +# -*- encoding: utf-8 -*- +############################################################################## +# +# OpenERP, Open Source Management Solution +# This module copyright (C) 2015 UAB Versada +# (). +# +# 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 . +# +############################################################################## diff --git a/partner_credit_limit_sale/__openerp__.py b/partner_credit_limit_sale/__openerp__.py new file mode 100644 index 000000000..42e054529 --- /dev/null +++ b/partner_credit_limit_sale/__openerp__.py @@ -0,0 +1,38 @@ +# -*- encoding: utf-8 -*- +############################################################################## +# +# OpenERP, Open Source Management Solution +# This module copyright (C) 2015 UAB Versada +# (). +# +# 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 . +# +############################################################################## + +{ + 'name': 'Partner Credit Limit', + 'version': '0.1', + 'author': 'Versada UAB,Odoo Community Association (OCA)', + 'category': 'Sale', + 'website': 'http://www.versada.lt', + 'depends': [ + 'partner_credit_limit', + 'sale' + ], + 'data': [ + 'data/sale.xml', + ], + 'installable': True, + 'application': False, +} diff --git a/partner_credit_limit_sale/data/sale.xml b/partner_credit_limit_sale/data/sale.xml new file mode 100644 index 000000000..5735b9c2e --- /dev/null +++ b/partner_credit_limit_sale/data/sale.xml @@ -0,0 +1,11 @@ + + + + + not partner_id.credit_limit_reached(credit_increase=amount_total) + + + not partner_id.credit_limit_reached(credit_increase=amount_total) + + +