Browse Source

Add new module pos_invoice_reconcile

pull/110/head
jcarlosmontoya 9 years ago
parent
commit
b49ba01235
  1. 1
      README.md
  2. 4
      pos_invoice_reconcile/README.rst
  3. 1
      pos_invoice_reconcile/__init__.py
  4. 39
      pos_invoice_reconcile/__openerp__.py
  5. 1
      pos_invoice_reconcile/models/__init__.py
  6. 79
      pos_invoice_reconcile/models/models.py

1
README.md

@ -18,6 +18,7 @@ addon | version | summary
[pos_customer_required](pos_customer_required/) | 8.0.1.0.1 | Point of Sale Require Customer
[pos_default_empty_image](pos_default_empty_image/) | 8.0.0.1.0 | Optimise load time for products with no image
[pos_gift_ticket](pos_gift_ticket/) | 8.0.0.1.0 | Gift Ticket
[pos_invoice_reconcile](pos_invoice_reconcile/) | 8.0.0.1.0 | Automatically reconciles invoiced orders
[pos_payment_terminal](pos_payment_terminal/) | 8.0.0.1.0 | Manage Payment Terminal device from POS front end
[pos_pricelist](pos_pricelist/) | 8.0.1.3.0 | Pricelist for Point of sale
[pos_product_template](pos_product_template/) | 8.0.0.2.0 | Manage Product Template in Front End Point Of Sale

4
pos_invoice_reconcile/README.rst

@ -0,0 +1,4 @@
POS Invoice Reconcile
======================
This module automatically reconciles invoiced orders in POS (when close session)
This module is based in .. _pos_autoreconcile: https://github.com/OCA/pos/pull/27

1
pos_invoice_reconcile/__init__.py

@ -0,0 +1 @@
import models

39
pos_invoice_reconcile/__openerp__.py

@ -0,0 +1,39 @@
# -*- encoding: utf-8 -*-
##############################################################################
#
# OpenERP, Open Source Management Solution
# This module copyright :
# (c) 2016 SDI
# Juan Carlos Montoya <jcmontoya@sdi.es>
# Javier Garcia <jgarcia@sdi.es>
#
# 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 Invoice auto reconcile",
"version": "8.0.0.1.0",
"author": "Juan Carlos Montoya",
"website": "http://sdi.es",
"license": "AGPL-3",
"category": "Accounting",
'summary': """
- Automatically Reconcile invoiced POS orders
""",
"depends": [
'point_of_sale',
],
"installable": True,
}

1
pos_invoice_reconcile/models/__init__.py

@ -0,0 +1 @@
import models

79
pos_invoice_reconcile/models/models.py

@ -0,0 +1,79 @@
# -*- encoding: utf-8 -*-
##############################################################################
#
# OpenERP, Open Source Management Solution
# This module copyright :
# (c) 2016 SDI
# Juan Carlos Montoya <jcmontoya@sdi.es>
# Javier Garcia <jgarcia@sdi.es>
#
# 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, fields, api, _
class PosSession(models.Model):
_inherit = 'pos.session'
# override _confirm_orders point_of_sale
@api.multi
def _confirm_orders(self):
acc_default = self.env['ir.property'].get(
'property_account_receivable', 'res.partner')
grouped_data = {}
# Filter only invoiced pos orders
orders = self.order_ids.filtered(lambda o: o.state == "invoiced")
for order in orders:
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
acc_default and acc_default.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 statement in order.statement_ids:
if statement.account_id.id != order_account:
continue
for line in statement.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.invoice_id.move_id.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)
# reconcile invoice
for key, value in grouped_data.iteritems():
if not value:
continue
context = self._context.copy()
context.update({'active_ids': value})
self.env['account.move.line.reconcile'].with_context(
context).trans_rec_reconcile_full()
grouped_data.clear()
return super(PosSession, self)._confirm_orders()
Loading…
Cancel
Save