Browse Source

[INIT][pos_trade_receivable_autoreconcile]

pull/24/head
Andrius Preimantas 10 years ago
parent
commit
bc860dc97a
  1. 54
      pos_trade_receivable_autoreconcile/README.rst
  2. 5
      pos_trade_receivable_autoreconcile/__init__.py
  3. 18
      pos_trade_receivable_autoreconcile/__openerp__.py
  4. 5
      pos_trade_receivable_autoreconcile/model/__init__.py
  5. 48
      pos_trade_receivable_autoreconcile/model/point_of_sale.py

54
pos_trade_receivable_autoreconcile/README.rst

@ -0,0 +1,54 @@
.. image:: https://img.shields.io/badge/licence-AGPL--3-blue.svg
:alt: License: AGPL-3
POS Trade Receivable Autoreconcile
==================================
This module reconciles "Trade Receivable" record created on Customer account
with Payments made by this customer.
Example:
* 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.
Usage
=====
* Install the module. No configuration needed.
Credits
=======
Contributors
------------
* Andrius Preimantas <andrius@versada.lt>
Maintainer
----------
.. image:: http://odoo-community.org/logo.png
:alt: Odoo Community Association
:target: http://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.

5
pos_trade_receivable_autoreconcile/__init__.py

@ -0,0 +1,5 @@
# -*- coding: utf-8 -*-
# This file is part of OpenERP. The COPYRIGHT file at the top level of
# this module contains the full copyright notices and license terms.
from . import model

18
pos_trade_receivable_autoreconcile/__openerp__.py

@ -0,0 +1,18 @@
# -*- coding: utf-8 -*-
# This file is part of OpenERP. The COPYRIGHT file at the top level of
# this module contains the full copyright notices and license terms.
{
'name': 'POS Trade Receivable Autoreconcile',
'version': '0.1',
'author': 'Versada UAB',
'category': 'Other',
'website': 'http://www.versada.lt',
'depends': [
'point_of_sale',
],
'data': [
],
'installable': True,
'application': False,
}

5
pos_trade_receivable_autoreconcile/model/__init__.py

@ -0,0 +1,5 @@
# -*- coding: utf-8 -*-
# This file is part of OpenERP. The COPYRIGHT file at the top level of
# this module contains the full copyright notices and license terms.
from . import point_of_sale

48
pos_trade_receivable_autoreconcile/model/point_of_sale.py

@ -0,0 +1,48 @@
# -*- coding: utf-8 -*-
# This file is part of OpenERP. The COPYRIGHT file at the top level of
# this module contains the full copyright notices and license terms.
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:
grouped_data[key].append(line.id)
for key, value in grouped_data.iteritems():
for line in order.account_move.line_id:
if line.account_id.id == key[1] and line.partner_id.id == key[0]:
grouped_data[key].append(line.id)
break
for key, value in grouped_data.iteritems():
self.pool.get('account.move.line').reconcile_partial(cr, uid, value)
return to_ret
Loading…
Cancel
Save