diff --git a/pos_autoreconcile/README.rst b/pos_autoreconcile/README.rst new file mode 100644 index 00000000..4e5fd867 --- /dev/null +++ b/pos_autoreconcile/README.rst @@ -0,0 +1,92 @@ +.. 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 + +================= +POS Autoreconcile +================= + +Module reconciles Invoices and "Trade Receivable" records with payments made by +related Customer. + +Example of "Trade Receivable" reconciliation: + +* Product costs 8EUR but customer pays 10EUR by cash getting 2EUR in return. +In accounting it looks like this: + +1) D: cash: 10 +2) C: account_receivable: 10 + +3) D: account_receivable: 2 +4) C: cash: 2 + +* When closing & validating a session system would create "Trade Receivable" +counterpart like this: + +5) D: account_receivable: 8 +6) C: income_account: 8 + +When this module is installed 2), 3) and 5) items would be reconciled when +closing a session. + +Module also grants access rights for POS users to create reconciliation records + +Installation +============ + +To install this module, you need to: + +* Click on Install button + +Configuration +============= + +No additional configuration is needed. + +Usage +===== + +To use this module, you need to: + +* operate your POS as usual + +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/pos_autoreconcile/__init__.py b/pos_autoreconcile/__init__.py new file mode 100644 index 00000000..ad75e006 --- /dev/null +++ b/pos_autoreconcile/__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/pos_autoreconcile/__openerp__.py b/pos_autoreconcile/__openerp__.py new file mode 100644 index 00000000..8e08a88a --- /dev/null +++ b/pos_autoreconcile/__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': 'POS Autoreconcile', + 'version': '0.1', + 'author': 'Versada UAB,Odoo Community Association (OCA)', + 'category': 'Point Of Sale', + 'website': 'http://www.versada.lt', + 'depends': [ + 'point_of_sale', + ], + 'data': [ + 'security/ir.model.access.csv', + ], + 'installable': True, + 'application': False, +} diff --git a/pos_autoreconcile/model/__init__.py b/pos_autoreconcile/model/__init__.py new file mode 100644 index 00000000..236f7c2f --- /dev/null +++ b/pos_autoreconcile/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 point_of_sale diff --git a/pos_autoreconcile/model/point_of_sale.py b/pos_autoreconcile/model/point_of_sale.py new file mode 100644 index 00000000..58a5d7a9 --- /dev/null +++ b/pos_autoreconcile/model/point_of_sale.py @@ -0,0 +1,73 @@ +# -*- 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 POSOrder(models.Model): + _inherit = "pos.order" + + def _create_account_move_line(self, cr, uid, ids, session=None, + move_id=None, context=None): + to_ret = super(POSOrder, self)._create_account_move_line( + cr, uid, ids, session=session, move_id=move_id, context=context) + + account_def = self.pool.get('ir.property').get( + cr, uid, 'property_account_receivable', 'res.partner') + + grouped_data = {} + + for order in self.browse(cr, uid, ids, context=context): + current_company = order.sale_journal.company_id + order_account = ( + order.partner_id and + order.partner_id.property_account_receivable and + order.partner_id.property_account_receivable.id or + account_def and account_def.id or + current_company.account_receivable.id + ) + debit = ((order.amount_total > 0) and order.amount_total) or 0.0 + key = (order.partner_id.id, order_account, debit > 0) + grouped_data.setdefault(key, []) + for each in order.statement_ids: + if each.account_id.id != order_account: + continue + + for line in each.journal_entry_id.line_id: + if (line.account_id.id == order_account and + line.state == 'valid'): + grouped_data[key].append(line.id) + for key, value in grouped_data.iteritems(): + for line in order.account_move.line_id: + if (line.partner_id.id == key[0] and + line.account_id.id == key[1] and + (line.debit > 0) == key[2] and + line.state == 'valid'): + grouped_data[key].append(line.id) + break + for key, value in grouped_data.iteritems(): + if not value: + continue + self.pool.get('account.move.line').reconcile_partial( + cr, uid, value) + + return to_ret diff --git a/pos_autoreconcile/security/ir.model.access.csv b/pos_autoreconcile/security/ir.model.access.csv new file mode 100644 index 00000000..e1ca47c6 --- /dev/null +++ b/pos_autoreconcile/security/ir.model.access.csv @@ -0,0 +1,2 @@ +id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink +access_account_move_reconcile,account.move.reconcile,account.model_account_move_reconcile,point_of_sale.group_pos_user,1,1,1,0