Browse Source

Merge pull request #27 from andrius-preimantas/pos_trade_receivable_autoreconcile

Pos autoreconcile
pull/110/merge
Sylvain LE GAL 8 years ago
committed by GitHub
parent
commit
037597f524
  1. 92
      pos_autoreconcile/README.rst
  2. 23
      pos_autoreconcile/__init__.py
  3. 37
      pos_autoreconcile/__openerp__.py
  4. 23
      pos_autoreconcile/model/__init__.py
  5. 73
      pos_autoreconcile/model/point_of_sale.py
  6. 2
      pos_autoreconcile/security/ir.model.access.csv

92
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 <https://github.com/OCA/pos/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 <https://github.com/OCA/pos/issues/new?body=module:%20pos_trade_receivable_autoreconcile%0Aversion:%208.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
Credits
=======
Contributors
------------
* Andrius Preimantas <andrius@versada.lt>
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.

23
pos_autoreconcile/__init__.py

@ -0,0 +1,23 @@
# -*- encoding: utf-8 -*-
##############################################################################
#
# OpenERP, Open Source Management Solution
# This module copyright (C) 2015 UAB Versada
# (<http://www.versada.lt>).
#
# 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 <http://www.gnu.org/licenses/>.
#
##############################################################################
from . import model

37
pos_autoreconcile/__openerp__.py

@ -0,0 +1,37 @@
# -*- encoding: utf-8 -*-
##############################################################################
#
# OpenERP, Open Source Management Solution
# This module copyright (C) 2015 UAB Versada
# (<http://www.versada.lt>).
#
# 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 <http://www.gnu.org/licenses/>.
#
##############################################################################
{
'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,
}

23
pos_autoreconcile/model/__init__.py

@ -0,0 +1,23 @@
# -*- encoding: utf-8 -*-
##############################################################################
#
# OpenERP, Open Source Management Solution
# This module copyright (C) 2015 UAB Versada
# (<http://www.versada.lt>).
#
# 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 <http://www.gnu.org/licenses/>.
#
##############################################################################
from . import point_of_sale

73
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
# (<http://www.versada.lt>).
#
# 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 <http://www.gnu.org/licenses/>.
#
##############################################################################
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

2
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
Loading…
Cancel
Save