mirror of
https://github.com/OCA/account-reconcile.git
synced 2025-01-20 12:27:39 +02:00
[ADD] account_reconciliation_widget: first working alpha
This commit is contained in:
86
account_reconciliation_widget/README.rst
Normal file
86
account_reconciliation_widget/README.rst
Normal file
@@ -0,0 +1,86 @@
|
||||
=============================
|
||||
account_reconciliation_widget
|
||||
=============================
|
||||
|
||||
.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
||||
!! This file is generated by oca-gen-addon-readme !!
|
||||
!! changes will be overwritten. !!
|
||||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
||||
|
||||
.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
|
||||
:target: https://odoo-community.org/page/development-status
|
||||
:alt: Beta
|
||||
.. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png
|
||||
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
|
||||
:alt: License: AGPL-3
|
||||
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Faccount_reconciliation_widget-lightgray.png?logo=github
|
||||
:target: https://github.com/OCA/account_reconciliation_widget/tree/14.0/account_reconciliation_widget
|
||||
:alt: OCA/account_reconciliation_widget
|
||||
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
|
||||
:target: https://translation.odoo-community.org/projects/account_reconciliation_widget-14-0/account_reconciliation_widget-14-0-account_reconciliation_widget
|
||||
:alt: Translate me on Weblate
|
||||
|
||||
|badge1| |badge2| |badge3| |badge4|
|
||||
|
||||
This module restores account reconciliation widget moved from Odoo community to enterpise in V. 14.0
|
||||
Provides two widgets designed to reconcile move lines in a easy way: one focused on bank statements and another for generic use.
|
||||
|
||||
**Table of contents**
|
||||
|
||||
.. contents::
|
||||
:local:
|
||||
|
||||
Usage
|
||||
=====
|
||||
|
||||
With an user with full accounting features enabled:
|
||||
|
||||
Invoicing --> Accounting --> Actions --> Reconciliation.
|
||||
|
||||
From journal items list view you can select check of them and click Action --> Reconcile.
|
||||
|
||||
From accounting dashboard you can use reconcile button in Bank / Cash journals.
|
||||
|
||||
Also, you can navigate to statements and use the reconcile button.
|
||||
|
||||
|
||||
Bug Tracker
|
||||
===========
|
||||
|
||||
Bugs are tracked on `GitHub Issues <https://github.com/OCA/account_reconciliation_widget/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 <https://github.com/OCA/account_reconciliation_widget/issues/new?body=module:%20account_reconciliation_widget%0Aversion:%2014.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
|
||||
|
||||
Do not contact contributors directly about support or help with technical issues.
|
||||
|
||||
Credits
|
||||
=======
|
||||
|
||||
Authors
|
||||
~~~~~~~
|
||||
|
||||
* Ozono Multimedia
|
||||
|
||||
Contributors
|
||||
~~~~~~~~~~~~
|
||||
|
||||
* Tecnativa - Pedro M. Baeza
|
||||
|
||||
|
||||
Maintainers
|
||||
~~~~~~~~~~~
|
||||
|
||||
This module is maintained by the OCA.
|
||||
|
||||
.. image:: https://odoo-community.org/logo.png
|
||||
:alt: Odoo Community Association
|
||||
:target: https://odoo-community.org
|
||||
|
||||
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.
|
||||
|
||||
This module is part of the `OCA/account_reconciliation_widget <https://github.com/OCA/account_reconciliation_widget/tree/14.0/account_reconciliation_widget>`_ project on GitHub.
|
||||
|
||||
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
|
||||
1
account_reconciliation_widget/__init__.py
Normal file
1
account_reconciliation_widget/__init__.py
Normal file
@@ -0,0 +1 @@
|
||||
from . import models
|
||||
24
account_reconciliation_widget/__manifest__.py
Normal file
24
account_reconciliation_widget/__manifest__.py
Normal file
@@ -0,0 +1,24 @@
|
||||
# Copyright 2020 Ozono Multimedia - Iván Antón
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||
|
||||
{
|
||||
"name": "account_reconciliation_widget",
|
||||
"version": "14.0.1.0.0",
|
||||
"category": "Accounting",
|
||||
"license": "AGPL-3",
|
||||
"summary": "Account reconciliation widget",
|
||||
"author": "Odoo, Ozono Multimedia, Odoo Community Association (OCA)",
|
||||
"website": "https://github.com/OCA/account-reconcile",
|
||||
"depends": ["account"],
|
||||
"data": [
|
||||
"security/ir.model.access.csv",
|
||||
"views/assets.xml",
|
||||
"views/account_view.xml",
|
||||
"views/account_bank_statement_view.xml",
|
||||
"views/account_journal_dashboard_view.xml",
|
||||
],
|
||||
"qweb": [
|
||||
"static/src/xml/account_reconciliation.xml",
|
||||
],
|
||||
"installable": True,
|
||||
}
|
||||
5
account_reconciliation_widget/models/__init__.py
Normal file
5
account_reconciliation_widget/models/__init__.py
Normal file
@@ -0,0 +1,5 @@
|
||||
from . import account_move
|
||||
from . import account_bank_statement
|
||||
from . import account_journal
|
||||
from . import reconciliation_widget
|
||||
from . import res_company
|
||||
@@ -33,6 +33,7 @@ class AccountBankStatementLine(models.Model):
|
||||
|
||||
_inherit = "account.bank.statement.line"
|
||||
|
||||
# FIXME: is this necessary now?
|
||||
move_name = fields.Char(
|
||||
string="Journal Entry Name",
|
||||
readonly=True,
|
||||
@@ -129,22 +130,23 @@ class AccountBankStatementLine(models.Model):
|
||||
and user_type_id not in account_types
|
||||
):
|
||||
account_types |= user_type_id
|
||||
if suspense_moves_mode:
|
||||
if any(not line.journal_entry_ids for line in self):
|
||||
raise UserError(
|
||||
_(
|
||||
"Some selected statement line were not already "
|
||||
"reconciled with an account move."
|
||||
)
|
||||
)
|
||||
else:
|
||||
if any(line.journal_entry_ids for line in self):
|
||||
raise UserError(
|
||||
_(
|
||||
"A selected statement line was already reconciled with "
|
||||
"an account move."
|
||||
)
|
||||
)
|
||||
# FIXME: review
|
||||
# if suspense_moves_mode:
|
||||
# if any(not line.journal_entry_ids for line in self):
|
||||
# raise UserError(
|
||||
# _(
|
||||
# "Some selected statement line were not already "
|
||||
# "reconciled with an account move."
|
||||
# )
|
||||
# )
|
||||
# else:
|
||||
# if any(line.journal_entry_ids for line in self):
|
||||
# raise UserError(
|
||||
# _(
|
||||
# "A selected statement line was already reconciled with "
|
||||
# "an account move."
|
||||
# )
|
||||
# )
|
||||
|
||||
# Fully reconciled moves are just linked to the bank statement
|
||||
total = self.amount
|
||||
@@ -171,7 +173,7 @@ class AccountBankStatementLine(models.Model):
|
||||
# it.
|
||||
aml_rec.move_id.date = self.date
|
||||
aml_rec.payment_id.payment_date = self.date
|
||||
aml_rec.move_id.post()
|
||||
aml_rec.move_id.action_post()
|
||||
# We check the paid status of the invoices reconciled with this
|
||||
# payment
|
||||
for invoice in aml_rec.payment_id.reconciled_invoice_ids:
|
||||
@@ -181,86 +183,10 @@ class AccountBankStatementLine(models.Model):
|
||||
# (eg. invoice), in which case we reconcile the existing and the new
|
||||
# move lines together, or being a write-off.
|
||||
if counterpart_aml_dicts or new_aml_dicts:
|
||||
|
||||
# Create the move
|
||||
self.sequence = self.statement_id.line_ids.ids.index(self.id) + 1
|
||||
move_vals = self._prepare_reconciliation_move(self.statement_id.name)
|
||||
if suspense_moves_mode:
|
||||
self.button_cancel_reconciliation()
|
||||
move = (
|
||||
self.env["account.move"]
|
||||
.with_context(default_journal_id=move_vals["journal_id"])
|
||||
.create(move_vals)
|
||||
)
|
||||
counterpart_moves = counterpart_moves | move
|
||||
|
||||
# Create The payment
|
||||
payment = self.env["account.payment"]
|
||||
partner_id = (
|
||||
self.partner_id
|
||||
or (aml_dict.get("move_line") and aml_dict["move_line"].partner_id)
|
||||
or self.env["res.partner"]
|
||||
)
|
||||
if abs(total) > 0.00001:
|
||||
payment_vals = self._prepare_payment_vals(total)
|
||||
if not payment_vals["partner_id"]:
|
||||
payment_vals["partner_id"] = partner_id.id
|
||||
if payment_vals["partner_id"] and len(account_types) == 1:
|
||||
payment_vals["partner_type"] = (
|
||||
"customer"
|
||||
if account_types == receivable_account_type
|
||||
else "supplier"
|
||||
)
|
||||
payment = payment.create(payment_vals)
|
||||
|
||||
# Complete dicts to create both counterpart move lines and write-offs
|
||||
to_create = counterpart_aml_dicts + new_aml_dicts
|
||||
date = self.date or fields.Date.today()
|
||||
for aml_dict in to_create:
|
||||
aml_dict["move_id"] = move.id
|
||||
aml_dict["partner_id"] = self.partner_id.id
|
||||
aml_dict["statement_line_id"] = self.id
|
||||
self._prepare_move_line_for_currency(aml_dict, date)
|
||||
|
||||
# Create write-offs
|
||||
for aml_dict in new_aml_dicts:
|
||||
aml_dict["payment_id"] = payment and payment.id or False
|
||||
aml_obj.with_context(check_move_validity=False).create(aml_dict)
|
||||
|
||||
# Create counterpart move lines and reconcile them
|
||||
for aml_dict in counterpart_aml_dicts:
|
||||
if (
|
||||
aml_dict["move_line"].payment_id
|
||||
and not aml_dict["move_line"].statement_line_id
|
||||
):
|
||||
aml_dict["move_line"].write({"statement_line_id": self.id})
|
||||
if aml_dict["move_line"].partner_id.id:
|
||||
aml_dict["partner_id"] = aml_dict["move_line"].partner_id.id
|
||||
aml_dict["account_id"] = aml_dict["move_line"].account_id.id
|
||||
aml_dict["payment_id"] = payment and payment.id or False
|
||||
|
||||
counterpart_move_line = aml_dict.pop("move_line")
|
||||
new_aml = aml_obj.with_context(check_move_validity=False).create(
|
||||
aml_dict
|
||||
counterpart_moves = self._create_counterpart_and_new_aml(
|
||||
counterpart_moves, counterpart_aml_dicts, new_aml_dicts
|
||||
)
|
||||
|
||||
(new_aml | counterpart_move_line).reconcile()
|
||||
|
||||
self._check_invoice_state(counterpart_move_line.move_id)
|
||||
|
||||
# Balance the move
|
||||
st_line_amount = -sum([x.balance for x in move.line_ids])
|
||||
aml_dict = self._prepare_reconciliation_move_line(move, st_line_amount)
|
||||
aml_dict["payment_id"] = payment and payment.id or False
|
||||
aml_obj.with_context(check_move_validity=False).create(aml_dict)
|
||||
|
||||
# Needs to be called manually as lines were created 1 by 1
|
||||
move.update_lines_tax_exigibility()
|
||||
move.post()
|
||||
# record the move name on the statement line to be able to retrieve
|
||||
# it in case of unreconciliation
|
||||
self.write({"move_name": move.name})
|
||||
payment and payment.write({"payment_reference": move.name})
|
||||
elif self.move_name:
|
||||
raise UserError(
|
||||
_(
|
||||
@@ -277,177 +203,71 @@ class AccountBankStatementLine(models.Model):
|
||||
if self.account_number and self.partner_id and not self.bank_account_id:
|
||||
# Search bank account without partner to handle the case the
|
||||
# res.partner.bank already exists but is set on a different partner.
|
||||
self.bank_account_id = self._find_or_create_bank_account()
|
||||
self.partner_bank_id = self._find_or_create_bank_account()
|
||||
|
||||
counterpart_moves._check_balanced()
|
||||
return counterpart_moves
|
||||
|
||||
def _prepare_reconciliation_move(self, move_ref):
|
||||
"""Prepare the dict of values to create the move from a statement line.
|
||||
This method may be overridden to adapt domain logic through model
|
||||
inheritance (make sure to call super() to establish a clean extension
|
||||
chain).
|
||||
|
||||
:param char move_ref: will be used as the reference of the generated
|
||||
account move
|
||||
:return: dict of value to create() the account.move
|
||||
"""
|
||||
ref = move_ref or ""
|
||||
if self.ref:
|
||||
ref = move_ref + " - " + self.ref if move_ref else self.ref
|
||||
data = {
|
||||
"type": "entry",
|
||||
"journal_id": self.statement_id.journal_id.id,
|
||||
"currency_id": self.statement_id.currency_id.id,
|
||||
"date": self.statement_id.accounting_date or self.date,
|
||||
"partner_id": self.partner_id.id,
|
||||
"ref": ref,
|
||||
}
|
||||
if self.move_name:
|
||||
data.update(name=self.move_name)
|
||||
return data
|
||||
|
||||
def _prepare_reconciliation_move_line(self, move, amount):
|
||||
"""Prepare the dict of values to balance the move.
|
||||
|
||||
:param recordset move: the account.move to link the move line
|
||||
:param dict move: a dict of vals of a account.move which will be created
|
||||
later
|
||||
:param float amount: the amount of transaction that wasn't already
|
||||
reconciled
|
||||
"""
|
||||
company_currency = self.journal_id.company_id.currency_id
|
||||
statement_currency = self.journal_id.currency_id or company_currency
|
||||
st_line_currency = self.currency_id or statement_currency
|
||||
amount_currency = False
|
||||
st_line_currency_rate = (
|
||||
self.currency_id and (self.amount_currency / self.amount) or False
|
||||
)
|
||||
if isinstance(move, dict):
|
||||
amount_sum = sum(x[2].get("amount_currency", 0) for x in move["line_ids"])
|
||||
else:
|
||||
amount_sum = sum(x.amount_currency for x in move.line_ids)
|
||||
# We have several use case here to compare the currency and amount
|
||||
# currency of counterpart line to balance the move:
|
||||
if (
|
||||
st_line_currency != company_currency
|
||||
and st_line_currency == statement_currency
|
||||
def _create_counterpart_and_new_aml(
|
||||
self, counterpart_moves, counterpart_aml_dicts, new_aml_dicts
|
||||
):
|
||||
# company in currency A, statement in currency B and transaction in
|
||||
# currency B
|
||||
# counterpart line must have currency B and correct amount is
|
||||
# inverse of already existing lines
|
||||
amount_currency = -amount_sum
|
||||
elif (
|
||||
st_line_currency != company_currency
|
||||
and statement_currency == company_currency
|
||||
):
|
||||
# company in currency A, statement in currency A and transaction in
|
||||
# currency B
|
||||
# counterpart line must have currency B and correct amount is
|
||||
# inverse of already existing lines
|
||||
amount_currency = -amount_sum
|
||||
elif (
|
||||
st_line_currency != company_currency
|
||||
and st_line_currency != statement_currency
|
||||
):
|
||||
# company in currency A, statement in currency B and transaction in
|
||||
# currency C
|
||||
# counterpart line must have currency B and use rate between B and
|
||||
# C to compute correct amount
|
||||
amount_currency = -amount_sum / st_line_currency_rate
|
||||
elif (
|
||||
st_line_currency == company_currency
|
||||
and statement_currency != company_currency
|
||||
):
|
||||
# company in currency A, statement in currency B and transaction in
|
||||
# currency A
|
||||
# counterpart line must have currency B and amount is computed using
|
||||
# the rate between A and B
|
||||
amount_currency = amount / st_line_currency_rate
|
||||
|
||||
# last case is company in currency A, statement in currency A and
|
||||
# transaction in currency A
|
||||
# and in this case counterpart line does not need any second currency
|
||||
# nor amount_currency
|
||||
aml_obj = self.env["account.move.line"]
|
||||
|
||||
# Check if default_debit or default_credit account are properly configured
|
||||
account_id = (
|
||||
amount >= 0
|
||||
and self.statement_id.journal_id.default_credit_account_id.id
|
||||
or self.statement_id.journal_id.default_debit_account_id.id
|
||||
)
|
||||
# Delete previous move_lines
|
||||
self.move_id.line_ids.with_context(force_delete=True).unlink()
|
||||
|
||||
if not account_id:
|
||||
raise UserError(
|
||||
_(
|
||||
"No default debit and credit account defined on journal %s "
|
||||
"(ids: %s)."
|
||||
% (
|
||||
self.statement_id.journal_id.name,
|
||||
self.statement_id.journal_id.ids,
|
||||
)
|
||||
)
|
||||
)
|
||||
# Create liquidity line
|
||||
liquidity_aml_dict = self._prepare_liquidity_move_line_vals()
|
||||
aml_obj.with_context(check_move_validity=False).create(liquidity_aml_dict)
|
||||
|
||||
aml_dict = {
|
||||
"name": self.name,
|
||||
"partner_id": self.partner_id and self.partner_id.id or False,
|
||||
"account_id": account_id,
|
||||
"credit": amount < 0 and -amount or 0.0,
|
||||
"debit": amount > 0 and amount or 0.0,
|
||||
"statement_line_id": self.id,
|
||||
"currency_id": statement_currency != company_currency
|
||||
and statement_currency.id
|
||||
or (st_line_currency != company_currency and st_line_currency.id or False),
|
||||
"amount_currency": amount_currency,
|
||||
}
|
||||
if isinstance(move, self.env["account.move"].__class__):
|
||||
aml_dict["move_id"] = move.id
|
||||
return aml_dict
|
||||
self.sequence = self.statement_id.line_ids.ids.index(self.id) + 1
|
||||
counterpart_moves = counterpart_moves | self.move_id
|
||||
|
||||
def _get_communication(self, payment_method_id):
|
||||
return self.name or ""
|
||||
# Complete dicts to create both counterpart move lines and write-offs
|
||||
to_create = counterpart_aml_dicts + new_aml_dicts
|
||||
date = self.date or fields.Date.today()
|
||||
for aml_dict in to_create:
|
||||
aml_dict["move_id"] = self.move_id.id
|
||||
aml_dict["partner_id"] = self.partner_id.id
|
||||
aml_dict["statement_line_id"] = self.id
|
||||
self._prepare_move_line_for_currency(aml_dict, date)
|
||||
|
||||
def _prepare_payment_vals(self, total):
|
||||
"""Prepare the dict of values to create the payment from a statement
|
||||
line. This method may be overridden for update dict
|
||||
through model inheritance (make sure to call super() to establish a
|
||||
clean extension chain).
|
||||
# Create write-offs
|
||||
for aml_dict in new_aml_dicts:
|
||||
aml_obj.with_context(check_move_validity=False).create(aml_dict)
|
||||
|
||||
:param float total: will be used as the amount of the generated payment
|
||||
:return: dict of value to create() the account.payment
|
||||
"""
|
||||
self.ensure_one()
|
||||
partner_type = False
|
||||
if self.partner_id:
|
||||
if total < 0:
|
||||
partner_type = "supplier"
|
||||
else:
|
||||
partner_type = "customer"
|
||||
if not partner_type and self.env.context.get("default_partner_type"):
|
||||
partner_type = self.env.context["default_partner_type"]
|
||||
currency = self.journal_id.currency_id or self.company_id.currency_id
|
||||
payment_methods = (
|
||||
(total > 0)
|
||||
and self.journal_id.inbound_payment_method_ids
|
||||
or self.journal_id.outbound_payment_method_ids
|
||||
)
|
||||
return {
|
||||
"payment_method_id": payment_methods and payment_methods[0].id or False,
|
||||
"payment_type": total > 0 and "inbound" or "outbound",
|
||||
"partner_id": self.partner_id.id,
|
||||
"partner_type": partner_type,
|
||||
"journal_id": self.statement_id.journal_id.id,
|
||||
"payment_date": self.date,
|
||||
"state": "reconciled",
|
||||
"currency_id": currency.id,
|
||||
"amount": abs(total),
|
||||
"communication": self._get_communication(
|
||||
payment_methods[0] if payment_methods else False
|
||||
),
|
||||
"name": self.statement_id.name or _("Bank Statement %s") % self.date,
|
||||
}
|
||||
# Create counterpart move lines and reconcile them
|
||||
aml_to_reconcile = []
|
||||
for aml_dict in counterpart_aml_dicts:
|
||||
if not aml_dict["move_line"].statement_line_id:
|
||||
aml_dict["move_line"].write({"statement_line_id": self.id})
|
||||
if aml_dict["move_line"].partner_id.id:
|
||||
aml_dict["partner_id"] = aml_dict["move_line"].partner_id.id
|
||||
aml_dict["account_id"] = aml_dict["move_line"].account_id.id
|
||||
|
||||
counterpart_move_line = aml_dict.pop("move_line")
|
||||
new_aml = aml_obj.with_context(check_move_validity=False).create(aml_dict)
|
||||
|
||||
aml_to_reconcile.append((new_aml, counterpart_move_line))
|
||||
|
||||
# Post to allow reconcile
|
||||
self.move_id.with_context(skip_account_move_synchronization=True).action_post()
|
||||
|
||||
# Reconcile new lines with counterpart
|
||||
for new_aml, counterpart_move_line in aml_to_reconcile:
|
||||
(new_aml | counterpart_move_line).reconcile()
|
||||
|
||||
self._check_invoice_state(counterpart_move_line.move_id)
|
||||
|
||||
# Needs to be called manually as lines were created 1 by 1
|
||||
self.move_id.update_lines_tax_exigibility()
|
||||
self.move_id.with_context(skip_account_move_synchronization=True).action_post()
|
||||
# record the move name on the statement line to be able to retrieve
|
||||
# it in case of unreconciliation
|
||||
self.write({"move_name": self.move_id.name})
|
||||
|
||||
return counterpart_moves
|
||||
|
||||
def _prepare_move_line_for_currency(self, aml_dict, date):
|
||||
self.ensure_one()
|
||||
|
||||
@@ -20,3 +20,18 @@ class AccountJournal(models.Model):
|
||||
"company_ids": self.mapped("company_id").ids,
|
||||
},
|
||||
}
|
||||
|
||||
def action_open_reconcile_to_check(self):
|
||||
self.ensure_one()
|
||||
ids = self.to_check_ids().ids
|
||||
action_context = {
|
||||
"show_mode_selector": False,
|
||||
"company_ids": self.mapped("company_id").ids,
|
||||
}
|
||||
action_context.update({"suspense_moves_mode": True})
|
||||
action_context.update({"statement_line_ids": ids})
|
||||
return {
|
||||
"type": "ir.actions.client",
|
||||
"tag": "bank_statement_reconciliation_view",
|
||||
"context": action_context,
|
||||
}
|
||||
|
||||
@@ -121,7 +121,7 @@ class AccountMoveLine(models.Model):
|
||||
|
||||
# post all the writeoff moves at once
|
||||
if writeoff_moves:
|
||||
writeoff_moves.post()
|
||||
writeoff_moves.action_post()
|
||||
|
||||
# Return the writeoff move.line which is to be reconciled
|
||||
return line_to_reconcile
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
import copy
|
||||
|
||||
from psycopg2 import sql
|
||||
|
||||
from odoo import _, api, models
|
||||
from odoo.exceptions import UserError
|
||||
from odoo.osv import expression
|
||||
@@ -86,8 +88,7 @@ class AccountReconciliation(models.AbstractModel):
|
||||
|
||||
# Blue lines = payment on bank account not assigned to a statement yet
|
||||
aml_accounts = [
|
||||
st_line.journal_id.default_credit_account_id.id,
|
||||
st_line.journal_id.default_debit_account_id.id,
|
||||
st_line.journal_id.default_account_id.id,
|
||||
]
|
||||
|
||||
if partner_id is None:
|
||||
@@ -106,7 +107,8 @@ class AccountReconciliation(models.AbstractModel):
|
||||
from_clause, where_clause, where_clause_params = (
|
||||
self.env["account.move.line"]._where_calc(domain).get_sql()
|
||||
)
|
||||
query_str = """
|
||||
query_str = sql.SQL(
|
||||
"""
|
||||
SELECT "account_move_line".id FROM {from_clause}
|
||||
{where_str}
|
||||
ORDER BY ("account_move_line".debit -
|
||||
@@ -120,6 +122,7 @@ class AccountReconciliation(models.AbstractModel):
|
||||
amount=st_line.amount,
|
||||
limit_str=limit and " LIMIT %s" or "",
|
||||
)
|
||||
)
|
||||
params = where_clause_params + (limit and [limit] or [])
|
||||
self.env["account.move"].flush()
|
||||
self.env["account.move.line"].flush()
|
||||
@@ -290,7 +293,6 @@ class AccountReconciliation(models.AbstractModel):
|
||||
"""
|
||||
if not bank_statement_line_ids:
|
||||
return {}
|
||||
suspense_moves_mode = self._context.get("suspense_moves_mode")
|
||||
bank_statements = (
|
||||
self.env["account.bank.statement.line"]
|
||||
.browse(bank_statement_line_ids)
|
||||
@@ -301,17 +303,13 @@ class AccountReconciliation(models.AbstractModel):
|
||||
SELECT line.id
|
||||
FROM account_bank_statement_line line
|
||||
LEFT JOIN res_partner p on p.id = line.partner_id
|
||||
WHERE line.account_id IS NULL
|
||||
INNER JOIN account_bank_statement st ON line.statement_id = st.id
|
||||
AND st.state = 'posted'
|
||||
WHERE line.is_reconciled = FALSE
|
||||
AND line.amount != 0.0
|
||||
AND line.id IN %(ids)s
|
||||
{cond}
|
||||
GROUP BY line.id
|
||||
""".format(
|
||||
cond=not suspense_moves_mode
|
||||
and """AND NOT EXISTS (SELECT 1 from account_move_line aml
|
||||
WHERE aml.statement_line_id = line.id)"""
|
||||
or "",
|
||||
)
|
||||
"""
|
||||
self.env.cr.execute(query, {"ids": tuple(bank_statement_line_ids)})
|
||||
|
||||
domain = [["id", "in", [line.get("id") for line in self.env.cr.dictfetchall()]]]
|
||||
@@ -327,6 +325,9 @@ class AccountReconciliation(models.AbstractModel):
|
||||
|
||||
results.update(
|
||||
{
|
||||
"statement_id": len(bank_statements_left) == 1
|
||||
and bank_statements_left.id
|
||||
or False,
|
||||
"statement_name": len(bank_statements_left) == 1
|
||||
and bank_statements_left.name
|
||||
or False,
|
||||
@@ -403,7 +404,6 @@ class AccountReconciliation(models.AbstractModel):
|
||||
)
|
||||
if aml_ids:
|
||||
aml = MoveLine.browse(aml_ids)
|
||||
aml._check_reconcile_validity()
|
||||
account = aml[0].account_id
|
||||
currency = account.currency_id or account.company_id.currency_id
|
||||
return {
|
||||
@@ -489,8 +489,7 @@ class AccountReconciliation(models.AbstractModel):
|
||||
WHERE l.account_id = a.id
|
||||
{inner_where}
|
||||
AND l.amount_residual != 0
|
||||
AND (move.state = 'posted' OR (move.state = 'draft'
|
||||
AND journal.post_at = 'bank_rec'))
|
||||
AND move.state = 'posted'
|
||||
)
|
||||
""".format(
|
||||
inner_where=is_partner and "AND l.partner_id = p.id" or " "
|
||||
@@ -504,8 +503,7 @@ class AccountReconciliation(models.AbstractModel):
|
||||
WHERE l.account_id = a.id
|
||||
{inner_where}
|
||||
AND l.amount_residual > 0
|
||||
AND (move.state = 'posted'
|
||||
OR (move.state = 'draft' AND journal.post_at = 'bank_rec'))
|
||||
AND move.state = 'posted'
|
||||
)
|
||||
AND EXISTS (
|
||||
SELECT NULL
|
||||
@@ -515,13 +513,13 @@ class AccountReconciliation(models.AbstractModel):
|
||||
WHERE l.account_id = a.id
|
||||
{inner_where}
|
||||
AND l.amount_residual < 0
|
||||
AND (move.state = 'posted'
|
||||
OR (move.state = 'draft' AND journal.post_at = 'bank_rec'))
|
||||
AND move.state = 'posted'
|
||||
)
|
||||
""".format(
|
||||
inner_where=is_partner and "AND l.partner_id = p.id" or " "
|
||||
)
|
||||
query = """
|
||||
query = sql.SQL(
|
||||
"""
|
||||
SELECT {select} account_id, account_name, account_code, max_date
|
||||
FROM (
|
||||
SELECT {inner_select}
|
||||
@@ -579,6 +577,7 @@ class AccountReconciliation(models.AbstractModel):
|
||||
"OR max_date > last_time_entries_checked)"
|
||||
or " ",
|
||||
)
|
||||
)
|
||||
self.env["account.move.line"].flush()
|
||||
self.env["account.account"].flush()
|
||||
self.env.cr.execute(query, locals())
|
||||
@@ -822,17 +821,6 @@ class AccountReconciliation(models.AbstractModel):
|
||||
# line
|
||||
domain = expression.AND([domain, [("company_id", "=", st_line.company_id.id)]])
|
||||
|
||||
# take only moves in valid state. Draft is accepted only when "Post At"
|
||||
# is set to "Bank Reconciliation" in the associated journal
|
||||
domain_post_at = [
|
||||
"|",
|
||||
"&",
|
||||
("move_id.state", "=", "draft"),
|
||||
("journal_id.post_at", "=", "bank_rec"),
|
||||
("move_id.state", "not in", ["draft", "cancel"]),
|
||||
]
|
||||
domain = expression.AND([domain, domain_post_at])
|
||||
|
||||
if st_line.company_id.account_bank_reconciliation_start:
|
||||
domain = expression.AND(
|
||||
[
|
||||
@@ -858,11 +846,7 @@ class AccountReconciliation(models.AbstractModel):
|
||||
"&",
|
||||
("reconciled", "=", False),
|
||||
("account_id", "=", account_id),
|
||||
"|",
|
||||
("move_id.state", "=", "posted"),
|
||||
"&",
|
||||
("move_id.state", "=", "draft"),
|
||||
("move_id.journal_id.post_at", "=", "bank_rec"),
|
||||
]
|
||||
domain = expression.AND([domain, [("balance", "!=", 0.0)]])
|
||||
if partner_id:
|
||||
@@ -1046,7 +1030,8 @@ class AccountReconciliation(models.AbstractModel):
|
||||
data = {
|
||||
"id": st_line.id,
|
||||
"ref": st_line.ref,
|
||||
"note": st_line.note or "",
|
||||
# FIXME: where to fill?
|
||||
# 'note': st_line.note or "",
|
||||
"name": st_line.name,
|
||||
"date": format_date(self.env, st_line.date),
|
||||
"amount": amount,
|
||||
@@ -1056,11 +1041,11 @@ class AccountReconciliation(models.AbstractModel):
|
||||
"journal_id": st_line.journal_id.id,
|
||||
"statement_id": st_line.statement_id.id,
|
||||
"account_id": [
|
||||
st_line.journal_id.default_debit_account_id.id,
|
||||
st_line.journal_id.default_debit_account_id.display_name,
|
||||
st_line.journal_id.default_account_id.id,
|
||||
st_line.journal_id.default_account_id.display_name,
|
||||
],
|
||||
"account_code": st_line.journal_id.default_debit_account_id.code,
|
||||
"account_name": st_line.journal_id.default_debit_account_id.name,
|
||||
"account_code": st_line.journal_id.default_account_id.code,
|
||||
"account_name": st_line.journal_id.default_account_id.name,
|
||||
"partner_name": st_line.partner_id.name,
|
||||
"communication_partner_name": st_line.partner_name,
|
||||
# Amount in the statement currency
|
||||
@@ -1091,20 +1076,19 @@ class AccountReconciliation(models.AbstractModel):
|
||||
where_str = where_clause and (" WHERE %s" % where_clause) or ""
|
||||
|
||||
# Get pairs
|
||||
query = """
|
||||
query = sql.SQL(
|
||||
"""
|
||||
SELECT a.id, b.id
|
||||
FROM account_move_line a, account_move_line b,
|
||||
account_move move_a, account_move move_b,
|
||||
account_journal journal_a, account_journal journal_b
|
||||
WHERE a.id != b.id
|
||||
AND move_a.id = a.move_id
|
||||
AND (move_a.state = 'posted'
|
||||
OR (move_a.state = 'draft' AND journal_a.post_at = 'bank_rec'))
|
||||
AND move_a.state = 'posted'
|
||||
AND move_a.journal_id = journal_a.id
|
||||
AND move_b.id = b.move_id
|
||||
AND move_b.journal_id = journal_b.id
|
||||
AND (move_b.state = 'posted'
|
||||
OR (move_b.state = 'draft' AND journal_b.post_at = 'bank_rec'))
|
||||
AND move_b.state = 'posted'
|
||||
AND a.amount_residual = -b.amount_residual
|
||||
AND a.balance != 0.0
|
||||
AND b.balance != 0.0
|
||||
@@ -1120,6 +1104,7 @@ class AccountReconciliation(models.AbstractModel):
|
||||
""".format(
|
||||
from_clause + where_str
|
||||
)
|
||||
)
|
||||
move_line_id = self.env.context.get("move_line_id") or None
|
||||
params = (
|
||||
[
|
||||
|
||||
1
account_reconciliation_widget/readme/CONTRIBUTORS.rst
Normal file
1
account_reconciliation_widget/readme/CONTRIBUTORS.rst
Normal file
@@ -0,0 +1 @@
|
||||
* Tecnativa - Pedro M. Baeza
|
||||
2
account_reconciliation_widget/readme/DESCRIPTION.rst
Normal file
2
account_reconciliation_widget/readme/DESCRIPTION.rst
Normal file
@@ -0,0 +1,2 @@
|
||||
This module restores account reconciliation widget moved from Odoo community to enterpise in V. 14.0
|
||||
Provides two widgets designed to reconcile move lines in a easy way: one focused on bank statements and another for generic use.
|
||||
9
account_reconciliation_widget/readme/USAGE.rst
Normal file
9
account_reconciliation_widget/readme/USAGE.rst
Normal file
@@ -0,0 +1,9 @@
|
||||
With an user with full accounting features enabled:
|
||||
|
||||
Invoicing --> Accounting --> Actions --> Reconciliation.
|
||||
|
||||
From journal items list view you can select check of them and click Action --> Reconcile.
|
||||
|
||||
From accounting dashboard you can use reconcile button in Bank / Cash journals.
|
||||
|
||||
Also, you can navigate to statements and use the reconcile button.
|
||||
@@ -0,0 +1,2 @@
|
||||
id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
|
||||
access_account_reconciliation_widget_group_invoice,account_reconciliation_widget.group_invoice,model_account_reconciliation_widget,account.group_account_invoice,1,1,1,1
|
||||
|
429
account_reconciliation_widget/static/description/index.html
Normal file
429
account_reconciliation_widget/static/description/index.html
Normal file
@@ -0,0 +1,429 @@
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||||
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
||||
<meta name="generator" content="Docutils: http://docutils.sourceforge.net/" />
|
||||
<title>account_reconciliation_widget</title>
|
||||
<style type="text/css">
|
||||
|
||||
/*
|
||||
:Author: David Goodger (goodger@python.org)
|
||||
:Id: $Id: html4css1.css 7952 2016-07-26 18:15:59Z milde $
|
||||
:Copyright: This stylesheet has been placed in the public domain.
|
||||
|
||||
Default cascading style sheet for the HTML output of Docutils.
|
||||
|
||||
See http://docutils.sf.net/docs/howto/html-stylesheets.html for how to
|
||||
customize this style sheet.
|
||||
*/
|
||||
|
||||
/* used to remove borders from tables and images */
|
||||
.borderless, table.borderless td, table.borderless th {
|
||||
border: 0 }
|
||||
|
||||
table.borderless td, table.borderless th {
|
||||
/* Override padding for "table.docutils td" with "! important".
|
||||
The right padding separates the table cells. */
|
||||
padding: 0 0.5em 0 0 ! important }
|
||||
|
||||
.first {
|
||||
/* Override more specific margin styles with "! important". */
|
||||
margin-top: 0 ! important }
|
||||
|
||||
.last, .with-subtitle {
|
||||
margin-bottom: 0 ! important }
|
||||
|
||||
.hidden {
|
||||
display: none }
|
||||
|
||||
.subscript {
|
||||
vertical-align: sub;
|
||||
font-size: smaller }
|
||||
|
||||
.superscript {
|
||||
vertical-align: super;
|
||||
font-size: smaller }
|
||||
|
||||
a.toc-backref {
|
||||
text-decoration: none ;
|
||||
color: black }
|
||||
|
||||
blockquote.epigraph {
|
||||
margin: 2em 5em ; }
|
||||
|
||||
dl.docutils dd {
|
||||
margin-bottom: 0.5em }
|
||||
|
||||
object[type="image/svg+xml"], object[type="application/x-shockwave-flash"] {
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
/* Uncomment (and remove this text!) to get bold-faced definition list terms
|
||||
dl.docutils dt {
|
||||
font-weight: bold }
|
||||
*/
|
||||
|
||||
div.abstract {
|
||||
margin: 2em 5em }
|
||||
|
||||
div.abstract p.topic-title {
|
||||
font-weight: bold ;
|
||||
text-align: center }
|
||||
|
||||
div.admonition, div.attention, div.caution, div.danger, div.error,
|
||||
div.hint, div.important, div.note, div.tip, div.warning {
|
||||
margin: 2em ;
|
||||
border: medium outset ;
|
||||
padding: 1em }
|
||||
|
||||
div.admonition p.admonition-title, div.hint p.admonition-title,
|
||||
div.important p.admonition-title, div.note p.admonition-title,
|
||||
div.tip p.admonition-title {
|
||||
font-weight: bold ;
|
||||
font-family: sans-serif }
|
||||
|
||||
div.attention p.admonition-title, div.caution p.admonition-title,
|
||||
div.danger p.admonition-title, div.error p.admonition-title,
|
||||
div.warning p.admonition-title, .code .error {
|
||||
color: red ;
|
||||
font-weight: bold ;
|
||||
font-family: sans-serif }
|
||||
|
||||
/* Uncomment (and remove this text!) to get reduced vertical space in
|
||||
compound paragraphs.
|
||||
div.compound .compound-first, div.compound .compound-middle {
|
||||
margin-bottom: 0.5em }
|
||||
|
||||
div.compound .compound-last, div.compound .compound-middle {
|
||||
margin-top: 0.5em }
|
||||
*/
|
||||
|
||||
div.dedication {
|
||||
margin: 2em 5em ;
|
||||
text-align: center ;
|
||||
font-style: italic }
|
||||
|
||||
div.dedication p.topic-title {
|
||||
font-weight: bold ;
|
||||
font-style: normal }
|
||||
|
||||
div.figure {
|
||||
margin-left: 2em ;
|
||||
margin-right: 2em }
|
||||
|
||||
div.footer, div.header {
|
||||
clear: both;
|
||||
font-size: smaller }
|
||||
|
||||
div.line-block {
|
||||
display: block ;
|
||||
margin-top: 1em ;
|
||||
margin-bottom: 1em }
|
||||
|
||||
div.line-block div.line-block {
|
||||
margin-top: 0 ;
|
||||
margin-bottom: 0 ;
|
||||
margin-left: 1.5em }
|
||||
|
||||
div.sidebar {
|
||||
margin: 0 0 0.5em 1em ;
|
||||
border: medium outset ;
|
||||
padding: 1em ;
|
||||
background-color: #ffffee ;
|
||||
width: 40% ;
|
||||
float: right ;
|
||||
clear: right }
|
||||
|
||||
div.sidebar p.rubric {
|
||||
font-family: sans-serif ;
|
||||
font-size: medium }
|
||||
|
||||
div.system-messages {
|
||||
margin: 5em }
|
||||
|
||||
div.system-messages h1 {
|
||||
color: red }
|
||||
|
||||
div.system-message {
|
||||
border: medium outset ;
|
||||
padding: 1em }
|
||||
|
||||
div.system-message p.system-message-title {
|
||||
color: red ;
|
||||
font-weight: bold }
|
||||
|
||||
div.topic {
|
||||
margin: 2em }
|
||||
|
||||
h1.section-subtitle, h2.section-subtitle, h3.section-subtitle,
|
||||
h4.section-subtitle, h5.section-subtitle, h6.section-subtitle {
|
||||
margin-top: 0.4em }
|
||||
|
||||
h1.title {
|
||||
text-align: center }
|
||||
|
||||
h2.subtitle {
|
||||
text-align: center }
|
||||
|
||||
hr.docutils {
|
||||
width: 75% }
|
||||
|
||||
img.align-left, .figure.align-left, object.align-left, table.align-left {
|
||||
clear: left ;
|
||||
float: left ;
|
||||
margin-right: 1em }
|
||||
|
||||
img.align-right, .figure.align-right, object.align-right, table.align-right {
|
||||
clear: right ;
|
||||
float: right ;
|
||||
margin-left: 1em }
|
||||
|
||||
img.align-center, .figure.align-center, object.align-center {
|
||||
display: block;
|
||||
margin-left: auto;
|
||||
margin-right: auto;
|
||||
}
|
||||
|
||||
table.align-center {
|
||||
margin-left: auto;
|
||||
margin-right: auto;
|
||||
}
|
||||
|
||||
.align-left {
|
||||
text-align: left }
|
||||
|
||||
.align-center {
|
||||
clear: both ;
|
||||
text-align: center }
|
||||
|
||||
.align-right {
|
||||
text-align: right }
|
||||
|
||||
/* reset inner alignment in figures */
|
||||
div.align-right {
|
||||
text-align: inherit }
|
||||
|
||||
/* div.align-center * { */
|
||||
/* text-align: left } */
|
||||
|
||||
.align-top {
|
||||
vertical-align: top }
|
||||
|
||||
.align-middle {
|
||||
vertical-align: middle }
|
||||
|
||||
.align-bottom {
|
||||
vertical-align: bottom }
|
||||
|
||||
ol.simple, ul.simple {
|
||||
margin-bottom: 1em }
|
||||
|
||||
ol.arabic {
|
||||
list-style: decimal }
|
||||
|
||||
ol.loweralpha {
|
||||
list-style: lower-alpha }
|
||||
|
||||
ol.upperalpha {
|
||||
list-style: upper-alpha }
|
||||
|
||||
ol.lowerroman {
|
||||
list-style: lower-roman }
|
||||
|
||||
ol.upperroman {
|
||||
list-style: upper-roman }
|
||||
|
||||
p.attribution {
|
||||
text-align: right ;
|
||||
margin-left: 50% }
|
||||
|
||||
p.caption {
|
||||
font-style: italic }
|
||||
|
||||
p.credits {
|
||||
font-style: italic ;
|
||||
font-size: smaller }
|
||||
|
||||
p.label {
|
||||
white-space: nowrap }
|
||||
|
||||
p.rubric {
|
||||
font-weight: bold ;
|
||||
font-size: larger ;
|
||||
color: maroon ;
|
||||
text-align: center }
|
||||
|
||||
p.sidebar-title {
|
||||
font-family: sans-serif ;
|
||||
font-weight: bold ;
|
||||
font-size: larger }
|
||||
|
||||
p.sidebar-subtitle {
|
||||
font-family: sans-serif ;
|
||||
font-weight: bold }
|
||||
|
||||
p.topic-title {
|
||||
font-weight: bold }
|
||||
|
||||
pre.address {
|
||||
margin-bottom: 0 ;
|
||||
margin-top: 0 ;
|
||||
font: inherit }
|
||||
|
||||
pre.literal-block, pre.doctest-block, pre.math, pre.code {
|
||||
margin-left: 2em ;
|
||||
margin-right: 2em }
|
||||
|
||||
pre.code .ln { color: grey; } /* line numbers */
|
||||
pre.code, code { background-color: #eeeeee }
|
||||
pre.code .comment, code .comment { color: #5C6576 }
|
||||
pre.code .keyword, code .keyword { color: #3B0D06; font-weight: bold }
|
||||
pre.code .literal.string, code .literal.string { color: #0C5404 }
|
||||
pre.code .name.builtin, code .name.builtin { color: #352B84 }
|
||||
pre.code .deleted, code .deleted { background-color: #DEB0A1}
|
||||
pre.code .inserted, code .inserted { background-color: #A3D289}
|
||||
|
||||
span.classifier {
|
||||
font-family: sans-serif ;
|
||||
font-style: oblique }
|
||||
|
||||
span.classifier-delimiter {
|
||||
font-family: sans-serif ;
|
||||
font-weight: bold }
|
||||
|
||||
span.interpreted {
|
||||
font-family: sans-serif }
|
||||
|
||||
span.option {
|
||||
white-space: nowrap }
|
||||
|
||||
span.pre {
|
||||
white-space: pre }
|
||||
|
||||
span.problematic {
|
||||
color: red }
|
||||
|
||||
span.section-subtitle {
|
||||
/* font-size relative to parent (h1..h6 element) */
|
||||
font-size: 80% }
|
||||
|
||||
table.citation {
|
||||
border-left: solid 1px gray;
|
||||
margin-left: 1px }
|
||||
|
||||
table.docinfo {
|
||||
margin: 2em 4em }
|
||||
|
||||
table.docutils {
|
||||
margin-top: 0.5em ;
|
||||
margin-bottom: 0.5em }
|
||||
|
||||
table.footnote {
|
||||
border-left: solid 1px black;
|
||||
margin-left: 1px }
|
||||
|
||||
table.docutils td, table.docutils th,
|
||||
table.docinfo td, table.docinfo th {
|
||||
padding-left: 0.5em ;
|
||||
padding-right: 0.5em ;
|
||||
vertical-align: top }
|
||||
|
||||
table.docutils th.field-name, table.docinfo th.docinfo-name {
|
||||
font-weight: bold ;
|
||||
text-align: left ;
|
||||
white-space: nowrap ;
|
||||
padding-left: 0 }
|
||||
|
||||
/* "booktabs" style (no vertical lines) */
|
||||
table.docutils.booktabs {
|
||||
border: 0px;
|
||||
border-top: 2px solid;
|
||||
border-bottom: 2px solid;
|
||||
border-collapse: collapse;
|
||||
}
|
||||
table.docutils.booktabs * {
|
||||
border: 0px;
|
||||
}
|
||||
table.docutils.booktabs th {
|
||||
border-bottom: thin solid;
|
||||
text-align: left;
|
||||
}
|
||||
|
||||
h1 tt.docutils, h2 tt.docutils, h3 tt.docutils,
|
||||
h4 tt.docutils, h5 tt.docutils, h6 tt.docutils {
|
||||
font-size: 100% }
|
||||
|
||||
ul.auto-toc {
|
||||
list-style-type: none }
|
||||
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div class="document" id="account-reconciliation-widget">
|
||||
<h1 class="title">account_reconciliation_widget</h1>
|
||||
|
||||
<!-- !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
||||
!! This file is generated by oca-gen-addon-readme !!
|
||||
!! changes will be overwritten. !!
|
||||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
|
||||
<p><a class="reference external" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external" href="http://www.gnu.org/licenses/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/licence-AGPL--3-blue.png" /></a> <a class="reference external" href="https://github.com/OCA/account_reconciliation_widget/tree/14.0/account_reconciliation_widget"><img alt="OCA/account_reconciliation_widget" src="https://img.shields.io/badge/github-OCA%2Faccount_reconciliation_widget-lightgray.png?logo=github" /></a> <a class="reference external" href="https://translation.odoo-community.org/projects/account_reconciliation_widget-14-0/account_reconciliation_widget-14-0-account_reconciliation_widget"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a></p>
|
||||
<p>This module restores account reconciliation widget moved from Odoo community to enterpise in V. 14.0
|
||||
Provides two widgets designed to reconcile move lines in a easy way: one focused on bank statements and another for generic use.</p>
|
||||
<p><strong>Table of contents</strong></p>
|
||||
<div class="contents local topic" id="contents">
|
||||
<ul class="simple">
|
||||
<li><a class="reference internal" href="#usage" id="id1">Usage</a></li>
|
||||
<li><a class="reference internal" href="#bug-tracker" id="id2">Bug Tracker</a></li>
|
||||
<li><a class="reference internal" href="#credits" id="id3">Credits</a><ul>
|
||||
<li><a class="reference internal" href="#authors" id="id4">Authors</a></li>
|
||||
<li><a class="reference internal" href="#contributors" id="id5">Contributors</a></li>
|
||||
<li><a class="reference internal" href="#maintainers" id="id6">Maintainers</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="section" id="usage">
|
||||
<h1><a class="toc-backref" href="#id1">Usage</a></h1>
|
||||
<p>With an user with full accounting features enabled:</p>
|
||||
<p>Invoicing –> Accounting –> Actions –> Reconciliation.</p>
|
||||
<p>From journal items list view you can select check of them and click Action –> Reconcile.</p>
|
||||
<p>From accounting dashboard you can use reconcile button in Bank / Cash journals.</p>
|
||||
<p>Also, you can navigate to statements and use the reconcile button.</p>
|
||||
</div>
|
||||
<div class="section" id="bug-tracker">
|
||||
<h1><a class="toc-backref" href="#id2">Bug Tracker</a></h1>
|
||||
<p>Bugs are tracked on <a class="reference external" href="https://github.com/OCA/account_reconciliation_widget/issues">GitHub Issues</a>.
|
||||
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
|
||||
<a class="reference external" href="https://github.com/OCA/account_reconciliation_widget/issues/new?body=module:%20account_reconciliation_widget%0Aversion:%2014.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
|
||||
<p>Do not contact contributors directly about support or help with technical issues.</p>
|
||||
</div>
|
||||
<div class="section" id="credits">
|
||||
<h1><a class="toc-backref" href="#id3">Credits</a></h1>
|
||||
<div class="section" id="authors">
|
||||
<h2><a class="toc-backref" href="#id4">Authors</a></h2>
|
||||
<ul class="simple">
|
||||
<li>Ozono Multimedia</li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="section" id="contributors">
|
||||
<h2><a class="toc-backref" href="#id5">Contributors</a></h2>
|
||||
<ul class="simple">
|
||||
<li>Tecnativa - Pedro M. Baeza</li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="section" id="maintainers">
|
||||
<h2><a class="toc-backref" href="#id6">Maintainers</a></h2>
|
||||
<p>This module is maintained by the OCA.</p>
|
||||
<a class="reference external image-reference" href="https://odoo-community.org"><img alt="Odoo Community Association" src="https://odoo-community.org/logo.png" /></a>
|
||||
<p>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.</p>
|
||||
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/account_reconciliation_widget/tree/14.0/account_reconciliation_widget">OCA/account_reconciliation_widget</a> project on GitHub.</p>
|
||||
<p>You are welcome to contribute. To learn how please visit <a class="reference external" href="https://odoo-community.org/page/Contribute">https://odoo-community.org/page/Contribute</a>.</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
@@ -32,7 +32,6 @@ odoo.define("account.ReconciliationClientAction", function (require) {
|
||||
close_statement: "_onCloseStatement",
|
||||
load_more: "_onLoadMore",
|
||||
reload: "reload",
|
||||
search: "_onSearch",
|
||||
navigation_move: "_onNavigationMove",
|
||||
},
|
||||
config: _.extend({}, AbstractAction.prototype.config, {
|
||||
@@ -52,6 +51,7 @@ odoo.define("account.ReconciliationClientAction", function (require) {
|
||||
|
||||
_onNavigationMove: function (ev) {
|
||||
var non_reconciled_keys = _.keys(
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
_.pick(this.model.lines, function (value, key, object) {
|
||||
return !value.reconciled;
|
||||
})
|
||||
@@ -86,7 +86,8 @@ odoo.define("account.ReconciliationClientAction", function (require) {
|
||||
this._super.apply(this, arguments);
|
||||
this.action_manager = parent;
|
||||
this.params = params;
|
||||
this.controlPanelParams.modelName = "account.bank.statement.line";
|
||||
this.searchModelConfig.modelName = "account.bank.statement.line";
|
||||
this.controlPanelProps.cp_content = {};
|
||||
this.model = new this.config.Model(this, {
|
||||
modelName: "account.reconciliation.widget",
|
||||
defaultDisplayQty:
|
||||
@@ -191,7 +192,10 @@ odoo.define("account.ReconciliationClientAction", function (require) {
|
||||
initialState.valuenow = valuenow;
|
||||
initialState.context = self.model.getContext();
|
||||
self.renderer.showRainbowMan(initialState);
|
||||
self.remove_cp();
|
||||
self.controlPanelProps.cp_content = {
|
||||
$buttons: $(),
|
||||
$pager: $(),
|
||||
};
|
||||
} else {
|
||||
// Create a notification if some lines have been reconciled automatically.
|
||||
if (initialState.valuenow > 0)
|
||||
@@ -234,12 +238,11 @@ odoo.define("account.ReconciliationClientAction", function (require) {
|
||||
this.$pager = $(
|
||||
QWeb.render("reconciliation.control.pager", {widget: this.renderer})
|
||||
);
|
||||
this.updateControlPanel({
|
||||
clear: true,
|
||||
cp_content: {
|
||||
|
||||
this.controlPanelProps.cp_content = {
|
||||
$buttons: $(),
|
||||
$pager: this.$pager,
|
||||
},
|
||||
});
|
||||
};
|
||||
this.renderer.$progress = this.$pager;
|
||||
$(this.renderer.$progress)
|
||||
.parent()
|
||||
@@ -248,12 +251,6 @@ odoo.define("account.ReconciliationClientAction", function (require) {
|
||||
}
|
||||
},
|
||||
|
||||
remove_cp: function () {
|
||||
this.updateControlPanel({
|
||||
clear: true,
|
||||
});
|
||||
},
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
// Private
|
||||
// --------------------------------------------------------------------------
|
||||
@@ -384,12 +381,11 @@ odoo.define("account.ReconciliationClientAction", function (require) {
|
||||
|
||||
/**
|
||||
* @private
|
||||
* @param {OdooEvent} ev
|
||||
* @param {Object} searchQuery
|
||||
*/
|
||||
_onSearch: function (ev) {
|
||||
_onSearch: function (searchQuery) {
|
||||
var self = this;
|
||||
ev.stopPropagation();
|
||||
this.model.domain = ev.data.domain;
|
||||
this.model.domain = searchQuery.domain;
|
||||
this.model.display_context = "search";
|
||||
self.reload().then(function () {
|
||||
self.renderer._updateProgressBar({
|
||||
@@ -402,7 +398,6 @@ odoo.define("account.ReconciliationClientAction", function (require) {
|
||||
_onActionPartialAmount: function (event) {
|
||||
var self = this;
|
||||
var handle = event.target.handle;
|
||||
var line = this.model.getLine(handle);
|
||||
var amount = this.model.getPartialReconcileAmount(handle, event.data);
|
||||
self._getWidget(handle).updatePartialAmount(event.data.data, amount);
|
||||
},
|
||||
@@ -413,12 +408,13 @@ odoo.define("account.ReconciliationClientAction", function (require) {
|
||||
* @private
|
||||
* @param {OdooEvent} event
|
||||
*/
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
_onCloseStatement: function (event) {
|
||||
var self = this;
|
||||
return this.model.closeStatement().then(function (result) {
|
||||
self.do_action({
|
||||
name: "Bank Statements",
|
||||
res_model: "account.bank.statement.line",
|
||||
res_model: "account.bank.statement",
|
||||
res_id: result,
|
||||
views: [[false, "form"]],
|
||||
type: "ir.actions.act_window",
|
||||
@@ -432,6 +428,7 @@ odoo.define("account.ReconciliationClientAction", function (require) {
|
||||
*
|
||||
* @param {OdooEvent} event
|
||||
*/
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
_onLoadMore: function (event) {
|
||||
return this._loadMore(this.model.defaultDisplayQty);
|
||||
},
|
||||
@@ -466,7 +463,7 @@ odoo.define("account.ReconciliationClientAction", function (require) {
|
||||
self.widgets.splice(index, 1);
|
||||
}
|
||||
});
|
||||
// Get number of widget and if less than constant and if there are more to laod, load until constant
|
||||
// Get number of widget and if less than constant and if there are more to load, load until constant
|
||||
if (
|
||||
self.widgets.length < self.model.defaultDisplayQty &&
|
||||
self.model.valuemax - self.model.valuenow >=
|
||||
|
||||
@@ -5,7 +5,6 @@ odoo.define("account.ReconciliationModel", function (require) {
|
||||
var field_utils = require("web.field_utils");
|
||||
var utils = require("web.utils");
|
||||
var session = require("web.session");
|
||||
var WarningDialog = require("web.CrashManager").WarningDialog;
|
||||
var core = require("web.core");
|
||||
var _t = core._t;
|
||||
|
||||
@@ -50,7 +49,7 @@ odoo.define("account.ReconciliationModel", function (require) {
|
||||
* label: string
|
||||
* amount: number - real amount
|
||||
* amount_str: string - formated amount
|
||||
* [already_paid]: boolean
|
||||
* [is_liquidity_line]: boolean
|
||||
* [partner_id]: integer
|
||||
* [partner_name]: string
|
||||
* [account_code]: string
|
||||
@@ -140,7 +139,6 @@ odoo.define("account.ReconciliationModel", function (require) {
|
||||
* @returns {Promise}
|
||||
*/
|
||||
addProposition: function (handle, mv_line_id) {
|
||||
var self = this;
|
||||
var line = this.getLine(handle);
|
||||
var prop = _.clone(_.find(line["mv_lines_" + line.mode], {id: mv_line_id}));
|
||||
this._addProposition(line, prop);
|
||||
@@ -307,11 +305,11 @@ odoo.define("account.ReconciliationModel", function (require) {
|
||||
closeStatement: function () {
|
||||
var self = this;
|
||||
return this._rpc({
|
||||
model: "account.bank.statement.line",
|
||||
method: "button_confirm_bank",
|
||||
args: [self.bank_statement_line_id.id],
|
||||
model: "account.bank.statement",
|
||||
method: "button_validate",
|
||||
args: [self.statement.statement_id],
|
||||
}).then(function () {
|
||||
return self.bank_statement_line_id.id;
|
||||
return self.statement.statement_id;
|
||||
});
|
||||
},
|
||||
/**
|
||||
@@ -807,6 +805,7 @@ odoo.define("account.ReconciliationModel", function (require) {
|
||||
// Check if we have another line with to_check and if yes don't change value of this proposition
|
||||
prop.to_check = line.reconciliation_proposition.some(function (
|
||||
rec_prop,
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
index
|
||||
) {
|
||||
return rec_prop.id !== prop.id && rec_prop.to_check;
|
||||
@@ -928,7 +927,7 @@ odoo.define("account.ReconciliationModel", function (require) {
|
||||
var props = _.filter(line.reconciliation_proposition, function (prop) {
|
||||
return !prop.invalid;
|
||||
});
|
||||
var computeLinePromise;
|
||||
var computeLinePromise = null;
|
||||
if (props.length === 0) {
|
||||
// Usability: if user has not chosen any lines and click validate, it has the same behavior
|
||||
// as creating a write-off of the same amount.
|
||||
@@ -951,13 +950,13 @@ odoo.define("account.ReconciliationModel", function (require) {
|
||||
partner_id: line.st_line.partner_id,
|
||||
counterpart_aml_dicts: _.map(
|
||||
_.filter(props, function (prop) {
|
||||
return !isNaN(prop.id) && !prop.already_paid;
|
||||
return !isNaN(prop.id) && !prop.is_liquidity_line;
|
||||
}),
|
||||
self._formatToProcessReconciliation.bind(self, line)
|
||||
),
|
||||
payment_aml_ids: _.pluck(
|
||||
_.filter(props, function (prop) {
|
||||
return !isNaN(prop.id) && prop.already_paid;
|
||||
return !isNaN(prop.id) && prop.is_liquidity_line;
|
||||
}),
|
||||
"id"
|
||||
),
|
||||
@@ -1124,7 +1123,7 @@ odoo.define("account.ReconciliationModel", function (require) {
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (!prop.already_paid && parseInt(prop.id)) {
|
||||
if (!prop.is_liquidity_line && parseInt(prop.id)) {
|
||||
prop.is_move_line = true;
|
||||
}
|
||||
reconciliation_proposition.push(prop);
|
||||
@@ -1135,6 +1134,7 @@ odoo.define("account.ReconciliationModel", function (require) {
|
||||
prop.__tax_to_recompute &&
|
||||
prop.base_amount
|
||||
) {
|
||||
// (OZM) REVISAR
|
||||
reconciliation_proposition = _.filter(
|
||||
reconciliation_proposition,
|
||||
function (p) {
|
||||
@@ -1170,10 +1170,10 @@ odoo.define("account.ReconciliationModel", function (require) {
|
||||
tax_ids: tax.tax_ids,
|
||||
tax_repartition_line_id:
|
||||
tax.tax_repartition_line_id,
|
||||
tag_ids: tax.tag_ids,
|
||||
tax_tag_ids: tax.tag_ids,
|
||||
amount: tax.amount,
|
||||
label: prop.label
|
||||
? prop.label + " " + tax.name
|
||||
name: prop.name
|
||||
? prop.name + " " + tax.name
|
||||
: tax.name,
|
||||
date: prop.date,
|
||||
account_id: tax.account_id
|
||||
@@ -1205,7 +1205,9 @@ odoo.define("account.ReconciliationModel", function (require) {
|
||||
reconciliation_proposition.push(tax_prop);
|
||||
});
|
||||
|
||||
prop.tag_ids = result.base_tags;
|
||||
prop.tax_tag_ids = self._formatMany2ManyTagsTax(
|
||||
result.base_tags || []
|
||||
);
|
||||
})
|
||||
);
|
||||
} else {
|
||||
@@ -1571,7 +1573,7 @@ odoo.define("account.ReconciliationModel", function (require) {
|
||||
var formatOptions = {
|
||||
currency_id: line.st_line.currency_id,
|
||||
};
|
||||
var amount;
|
||||
var amount = 0;
|
||||
switch (values.amount_type) {
|
||||
case "percentage":
|
||||
amount = (line.balance.amount * values.amount) / 100;
|
||||
@@ -1580,7 +1582,6 @@ odoo.define("account.ReconciliationModel", function (require) {
|
||||
var matching = line.st_line.name.match(
|
||||
new RegExp(values.amount_from_label_regex)
|
||||
);
|
||||
amount = 0;
|
||||
if (matching && matching.length == 2) {
|
||||
matching = matching[1].replace(
|
||||
new RegExp("\\D" + values.decimal_separator, "g"),
|
||||
@@ -1714,7 +1715,7 @@ odoo.define("account.ReconciliationModel", function (require) {
|
||||
function (prop) {
|
||||
return _.isNumber(prop.id) ? prop.id : null;
|
||||
}
|
||||
).filter((id) => id != null);
|
||||
).filter((id) => id !== null);
|
||||
var filter = line["filter_" + mode] || "";
|
||||
return this._rpc({
|
||||
model: "account.reconciliation.widget",
|
||||
@@ -1783,8 +1784,8 @@ odoo.define("account.ReconciliationModel", function (require) {
|
||||
* @param {Object[]} data.moves list of processed account.move
|
||||
* @returns {Deferred}
|
||||
*/
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
_validatePostProcess: function (data) {
|
||||
var self = this;
|
||||
return Promise.resolve();
|
||||
},
|
||||
});
|
||||
@@ -2288,7 +2289,7 @@ odoo.define("account.ReconciliationModel", function (require) {
|
||||
function (prop) {
|
||||
return _.isNumber(prop.id) ? prop.id : null;
|
||||
}
|
||||
).filter((id) => id != null);
|
||||
).filter((id) => id !== null);
|
||||
var filter = line.filter_match || "";
|
||||
var args = [
|
||||
line.account_id.id,
|
||||
|
||||
@@ -35,7 +35,6 @@ odoo.define("account.ReconciliationRenderer", function (require) {
|
||||
* @override
|
||||
*/
|
||||
start: function () {
|
||||
var self = this;
|
||||
var defs = [this._super.apply(this, arguments)];
|
||||
this.time = Date.now();
|
||||
this.$progress = $("");
|
||||
@@ -98,7 +97,6 @@ odoo.define("account.ReconciliationRenderer", function (require) {
|
||||
* @param {[object]} [state.notifications]
|
||||
*/
|
||||
update: function (state) {
|
||||
var self = this;
|
||||
this._updateProgressBar(state);
|
||||
|
||||
if (state.valuenow === state.valuemax && !this.$(".done_message").length) {
|
||||
@@ -147,6 +145,7 @@ odoo.define("account.ReconciliationRenderer", function (require) {
|
||||
* close and then open form view of bank statement
|
||||
* @param {MouseEvent} event
|
||||
*/
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
_onCloseBankStatement: function (e) {
|
||||
this.trigger_up("close_statement");
|
||||
},
|
||||
@@ -215,6 +214,7 @@ odoo.define("account.ReconciliationRenderer", function (require) {
|
||||
* @private
|
||||
* @param {MouseEvent} event
|
||||
*/
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
_onLoadMore: function (e) {
|
||||
this.trigger_up("load_more");
|
||||
},
|
||||
@@ -428,7 +428,6 @@ odoo.define("account.ReconciliationRenderer", function (require) {
|
||||
|
||||
// Search propositions that could be a partial credit/debit.
|
||||
var props = [];
|
||||
var balance = state.balance.amount_currency;
|
||||
_.each(state.reconciliation_proposition, function (prop) {
|
||||
if (prop.display) {
|
||||
props.push(prop);
|
||||
@@ -460,8 +459,6 @@ odoo.define("account.ReconciliationRenderer", function (require) {
|
||||
var matching_modes = self.model.modes.filter((x) => x.startsWith("match"));
|
||||
for (let i = 0; i < matching_modes.length; i++) {
|
||||
var stateMvLines = state["mv_lines_" + matching_modes[i]] || [];
|
||||
var recs_count =
|
||||
stateMvLines.length > 0 ? stateMvLines[0].recs_count : 0;
|
||||
var remaining = state["remaining_" + matching_modes[i]];
|
||||
var $mv_lines = this.$(
|
||||
'div[id*="notebook_page_' +
|
||||
@@ -517,7 +514,7 @@ odoo.define("account.ReconciliationRenderer", function (require) {
|
||||
|
||||
// Create form
|
||||
if (state.createForm) {
|
||||
var createPromise;
|
||||
var createPromise = null;
|
||||
if (!this.fields.account_id) {
|
||||
createPromise = this._renderCreate(state);
|
||||
}
|
||||
@@ -822,6 +819,11 @@ odoo.define("account.ReconciliationRenderer", function (require) {
|
||||
group_acc: self.group_acc,
|
||||
})
|
||||
);
|
||||
|
||||
function addRequiredStyle(widget) {
|
||||
widget.$el.addClass("o_required_modifier");
|
||||
}
|
||||
|
||||
self.fields.account_id
|
||||
.appendTo($create.find(".create_account_id .o_td_field"))
|
||||
.then(addRequiredStyle.bind(self, self.fields.account_id));
|
||||
@@ -851,10 +853,6 @@ odoo.define("account.ReconciliationRenderer", function (require) {
|
||||
$create.find(".create_to_check .o_td_field")
|
||||
);
|
||||
self.$(".create").append($create);
|
||||
|
||||
function addRequiredStyle(widget) {
|
||||
widget.$el.addClass("o_required_modifier");
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
@@ -1060,7 +1058,9 @@ odoo.define("account.ReconciliationRenderer", function (require) {
|
||||
* @param {MouseEvent} event
|
||||
*/
|
||||
_onQuickCreateProposition: function (event) {
|
||||
document.activeElement && document.activeElement.blur();
|
||||
if (document.activeElement) {
|
||||
document.activeElement.blur();
|
||||
}
|
||||
this.trigger_up("quick_create_proposition", {
|
||||
data: $(event.target).data("reconcile-model-id"),
|
||||
});
|
||||
@@ -1069,7 +1069,9 @@ odoo.define("account.ReconciliationRenderer", function (require) {
|
||||
* @private
|
||||
*/
|
||||
_onCreateProposition: function () {
|
||||
document.activeElement && document.activeElement.blur();
|
||||
if (document.activeElement) {
|
||||
document.activeElement.blur();
|
||||
}
|
||||
var invalid = [];
|
||||
_.each(this.fields, function (field) {
|
||||
if (!field.isValid()) {
|
||||
|
||||
@@ -66,7 +66,7 @@
|
||||
rel="do_action"
|
||||
data-action_name="Unpaid Customer Invoices"
|
||||
data-model="account.move"
|
||||
data-domain="[('type', 'in', ('out_invoice', 'out_refund'))]"
|
||||
data-domain="[('move_type', 'in', ('out_invoice', 'out_refund'))]"
|
||||
data-context="{'search_default_unpaid': 1}"
|
||||
>unpaid invoices</a> and follow-up customers</li>
|
||||
<li>Pay your <a
|
||||
@@ -74,7 +74,7 @@
|
||||
rel="do_action"
|
||||
data-action_name="Unpaid Vendor Bills"
|
||||
data-model="account.move"
|
||||
data-domain="[('type', 'in', ('in_invoice', 'in_refund'))]"
|
||||
data-domain="[('move_type', 'in', ('in_invoice', 'in_refund'))]"
|
||||
data-context="{'search_default_unpaid': 1}"
|
||||
>vendor bills</a></li>
|
||||
<li>Check all <a
|
||||
|
||||
@@ -1,4 +1,9 @@
|
||||
odoo.define("account.reconciliation_tests.data", function () {
|
||||
/* global QUnit*/
|
||||
|
||||
odoo.define("account_reconciliation_widget.reconciliation_tests.data", function (
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
require
|
||||
) {
|
||||
"use strict";
|
||||
|
||||
/*
|
||||
@@ -11,6 +16,15 @@ odoo.define("account.reconciliation_tests.data", function () {
|
||||
|
||||
var Datas = {};
|
||||
|
||||
var options = {
|
||||
context: {
|
||||
statement_line_ids: [4],
|
||||
},
|
||||
params: {
|
||||
limitMoveLines: 5,
|
||||
},
|
||||
};
|
||||
|
||||
var db = {
|
||||
"res.company": {
|
||||
fields: {
|
||||
@@ -2016,15 +2030,6 @@ odoo.define("account.reconciliation_tests.data", function () {
|
||||
},
|
||||
};
|
||||
|
||||
var options = {
|
||||
context: {
|
||||
statement_line_ids: [4],
|
||||
},
|
||||
params: {
|
||||
limitMoveLines: 5,
|
||||
},
|
||||
};
|
||||
|
||||
Datas.params = {
|
||||
data: db,
|
||||
data_preprocess: data_preprocess,
|
||||
@@ -2043,19 +2048,19 @@ odoo.define("account.reconciliation_tests.data", function () {
|
||||
return Datas;
|
||||
});
|
||||
|
||||
odoo.define("account.reconciliation_tests", function (require) {
|
||||
odoo.define("account_reconciliation_widget.reconciliation_tests", function (require) {
|
||||
"use strict";
|
||||
|
||||
var ReconciliationClientAction = require("account.ReconciliationClientAction");
|
||||
var ReconciliationRenderer = require("account.ReconciliationRenderer");
|
||||
var demoData = require("account.reconciliation_tests.data");
|
||||
var demoData = require("account_reconciliation_widget.reconciliation_tests.data");
|
||||
|
||||
var testUtils = require("web.test_utils");
|
||||
var testUtilsDom = require("web.test_utils_dom");
|
||||
var testUtilsMock = require("web.test_utils_mock");
|
||||
|
||||
QUnit.module(
|
||||
"account",
|
||||
"account_reconciliation_widget",
|
||||
{
|
||||
beforeEach: function () {
|
||||
this.params = demoData.getParams();
|
||||
@@ -2413,7 +2418,9 @@ odoo.define("account.reconciliation_tests", function (require) {
|
||||
"Should call process_bank_statement_line with args"
|
||||
);
|
||||
var def = testUtils.makeTestPromise();
|
||||
def.abort = function () {};
|
||||
def.abort = function () {
|
||||
// Do nothing.
|
||||
};
|
||||
event.data.callback(def);
|
||||
}
|
||||
});
|
||||
@@ -2469,7 +2476,6 @@ odoo.define("account.reconciliation_tests", function (require) {
|
||||
to_check: false,
|
||||
counterpart_aml_dicts: [],
|
||||
payment_aml_ids: [],
|
||||
to_check: false,
|
||||
new_aml_dicts: [
|
||||
{
|
||||
account_id: 287,
|
||||
@@ -2485,7 +2491,9 @@ odoo.define("account.reconciliation_tests", function (require) {
|
||||
"Should call process_bank_statement_line with ids"
|
||||
);
|
||||
var def = testUtils.makeTestPromise();
|
||||
def.abort = function () {};
|
||||
def.abort = function () {
|
||||
// Do nothing.
|
||||
};
|
||||
event.data.callback(def);
|
||||
});
|
||||
|
||||
@@ -2575,7 +2583,9 @@ odoo.define("account.reconciliation_tests", function (require) {
|
||||
"Should call process_bank_statement_line with ids"
|
||||
);
|
||||
var def = testUtils.makeTestPromise();
|
||||
def.abort = function () {};
|
||||
def.abort = function () {
|
||||
// Do nothing.
|
||||
};
|
||||
event.data.callback(def);
|
||||
});
|
||||
|
||||
@@ -2759,8 +2769,6 @@ odoo.define("account.reconciliation_tests", function (require) {
|
||||
await clientAction.appendTo($("#qunit-fixture"));
|
||||
await testUtils.nextTick();
|
||||
|
||||
var widget = clientAction.widgets[0];
|
||||
|
||||
assert.strictEqual(
|
||||
clientAction
|
||||
.$(
|
||||
@@ -2771,7 +2779,6 @@ odoo.define("account.reconciliation_tests", function (require) {
|
||||
"$ 1,175.00$ 32.58$ 2,000.00",
|
||||
"should display the different amounts with the currency"
|
||||
);
|
||||
// Await testUtils.dom.click(widget.$('.accounting_view thead .mv_line td:first'));
|
||||
|
||||
assert.strictEqual(
|
||||
clientAction
|
||||
@@ -4818,7 +4825,9 @@ odoo.define("account.reconciliation_tests", function (require) {
|
||||
"Should call process_bank_statement_line with to_check set to true"
|
||||
);
|
||||
var def = testUtils.makeTestPromise();
|
||||
def.abort = function () {};
|
||||
def.abort = function () {
|
||||
// Do nothing.
|
||||
};
|
||||
event.data.callback(def);
|
||||
});
|
||||
|
||||
|
||||
1
account_reconciliation_widget/tests/__init__.py
Normal file
1
account_reconciliation_widget/tests/__init__.py
Normal file
@@ -0,0 +1 @@
|
||||
from . import test_reconciliation_widget
|
||||
@@ -0,0 +1,239 @@
|
||||
import logging
|
||||
import time
|
||||
|
||||
import requests
|
||||
|
||||
import odoo.tests
|
||||
|
||||
from odoo.addons.account.tests.common import TestAccountReconciliationCommon
|
||||
|
||||
_logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
@odoo.tests.tagged("post_install", "-at_install")
|
||||
class TestUi(odoo.tests.HttpCase):
|
||||
def test_01_admin_bank_statement_reconciliation(self):
|
||||
bank_stmt_name = "BNK/%s/0001" % time.strftime("%Y")
|
||||
bank_stmt_line = (
|
||||
self.env["account.bank.statement"]
|
||||
.search([("name", "=", bank_stmt_name)])
|
||||
.mapped("line_ids")
|
||||
)
|
||||
if not bank_stmt_line:
|
||||
_logger.info(
|
||||
"Tour bank_statement_reconciliation skipped: bank statement %s "
|
||||
"not found." % bank_stmt_name
|
||||
)
|
||||
return
|
||||
|
||||
admin = self.env.ref("base.user_admin")
|
||||
|
||||
# Tour can't be run if the setup if not the generic one.
|
||||
generic_coa = self.env.ref(
|
||||
"l10n_generic_coa.configurable_chart_template", raise_if_not_found=False
|
||||
)
|
||||
if (
|
||||
not admin.company_id.chart_template_id
|
||||
or admin.company_id.chart_template_id != generic_coa
|
||||
):
|
||||
_logger.info(
|
||||
"Tour bank_statement_reconciliation skipped: generic coa not found."
|
||||
)
|
||||
return
|
||||
|
||||
# To be able to test reconciliation, admin user must have access to
|
||||
# accounting features, so we give him the right group for that
|
||||
admin.write({"groups_id": [(4, self.env.ref("account.group_account_user").id)]})
|
||||
|
||||
payload = {
|
||||
"action": "bank_statement_reconciliation_view",
|
||||
"statement_line_ids[]": bank_stmt_line.ids,
|
||||
}
|
||||
prep = requests.models.PreparedRequest()
|
||||
prep.prepare_url(url="http://localhost/web#", params=payload)
|
||||
|
||||
self.start_tour(
|
||||
prep.url.replace("http://localhost", "").replace("?", "#"),
|
||||
"bank_statement_reconciliation",
|
||||
login="admin",
|
||||
)
|
||||
|
||||
|
||||
@odoo.tests.tagged("post_install", "-at_install")
|
||||
class TestReconciliationWidget(TestAccountReconciliationCommon):
|
||||
@classmethod
|
||||
def setUpClass(cls, chart_template_ref=None):
|
||||
super().setUpClass(chart_template_ref=chart_template_ref)
|
||||
|
||||
cls.acc_bank_stmt_model = cls.env["account.bank.statement"]
|
||||
cls.acc_bank_stmt_line_model = cls.env["account.bank.statement.line"]
|
||||
|
||||
def test_statement_suggestion_other_currency(self):
|
||||
# company currency is EUR
|
||||
# payment in USD
|
||||
invoice = self.create_invoice(
|
||||
invoice_amount=50, currency_id=self.currency_usd_id
|
||||
)
|
||||
|
||||
# journal currency in USD
|
||||
|
||||
bank_stmt = self.acc_bank_stmt_model.create(
|
||||
{
|
||||
"journal_id": self.bank_journal_usd.id,
|
||||
"date": time.strftime("%Y-07-15"),
|
||||
"name": "payment %s" % invoice.name,
|
||||
}
|
||||
)
|
||||
|
||||
bank_stmt_line = self.acc_bank_stmt_line_model.create(
|
||||
{
|
||||
"payment_ref": "payment",
|
||||
"statement_id": bank_stmt.id,
|
||||
"partner_id": self.partner_agrolait_id,
|
||||
"amount": 50,
|
||||
"date": time.strftime("%Y-07-15"),
|
||||
}
|
||||
)
|
||||
|
||||
result = self.env["account.reconciliation.widget"].get_bank_statement_line_data(
|
||||
bank_stmt_line.ids
|
||||
)
|
||||
self.assertEqual(
|
||||
result["lines"][0]["reconciliation_proposition"][0]["amount_str"], "$ 50.00"
|
||||
)
|
||||
|
||||
def test_filter_partner1(self):
|
||||
inv1 = self.create_invoice(currency_id=self.currency_euro_id)
|
||||
inv2 = self.create_invoice(currency_id=self.currency_euro_id)
|
||||
partner = inv1.partner_id
|
||||
|
||||
receivable1 = inv1.line_ids.filtered(
|
||||
lambda l: l.account_id.internal_type == "receivable"
|
||||
)
|
||||
receivable2 = inv2.line_ids.filtered(
|
||||
lambda l: l.account_id.internal_type == "receivable"
|
||||
)
|
||||
|
||||
bank_stmt = self.acc_bank_stmt_model.create(
|
||||
{
|
||||
"company_id": self.env.ref("base.main_company").id,
|
||||
"journal_id": self.bank_journal_euro.id,
|
||||
"date": time.strftime("%Y-07-15"),
|
||||
"name": "test",
|
||||
}
|
||||
)
|
||||
|
||||
bank_stmt_line = self.acc_bank_stmt_line_model.create(
|
||||
{
|
||||
"name": "testLine",
|
||||
"statement_id": bank_stmt.id,
|
||||
"amount": 100,
|
||||
"date": time.strftime("%Y-07-15"),
|
||||
"payment_ref": "test",
|
||||
}
|
||||
)
|
||||
|
||||
# This is like input a partner in the widget
|
||||
mv_lines_rec = self.env[
|
||||
"account.reconciliation.widget"
|
||||
].get_move_lines_for_bank_statement_line(
|
||||
bank_stmt_line.id,
|
||||
partner_id=partner.id,
|
||||
excluded_ids=[],
|
||||
search_str=False,
|
||||
mode="rp",
|
||||
)
|
||||
mv_lines_ids = [line["id"] for line in mv_lines_rec]
|
||||
|
||||
self.assertIn(receivable1.id, mv_lines_ids)
|
||||
self.assertIn(receivable2.id, mv_lines_ids)
|
||||
|
||||
# With a partner set, type the invoice reference in the filter
|
||||
mv_lines_rec = self.env[
|
||||
"account.reconciliation.widget"
|
||||
].get_move_lines_for_bank_statement_line(
|
||||
bank_stmt_line.id,
|
||||
partner_id=partner.id,
|
||||
excluded_ids=[],
|
||||
search_str=inv1.payment_reference,
|
||||
mode="rp",
|
||||
)
|
||||
mv_lines_ids = [line["id"] for line in mv_lines_rec]
|
||||
|
||||
self.assertIn(receivable1.id, mv_lines_ids)
|
||||
self.assertNotIn(receivable2.id, mv_lines_ids)
|
||||
|
||||
# Without a partner set, type "deco" in the filter
|
||||
mv_lines_rec = self.env[
|
||||
"account.reconciliation.widget"
|
||||
].get_move_lines_for_bank_statement_line(
|
||||
bank_stmt_line.id,
|
||||
partner_id=False,
|
||||
excluded_ids=[],
|
||||
search_str="deco",
|
||||
mode="rp",
|
||||
)
|
||||
mv_lines_ids = [line["id"] for line in mv_lines_rec]
|
||||
|
||||
self.assertIn(receivable1.id, mv_lines_ids)
|
||||
self.assertIn(receivable2.id, mv_lines_ids)
|
||||
|
||||
# With a partner set, type "deco" in the filter and click on the first
|
||||
# receivable
|
||||
mv_lines_rec = self.env[
|
||||
"account.reconciliation.widget"
|
||||
].get_move_lines_for_bank_statement_line(
|
||||
bank_stmt_line.id,
|
||||
partner_id=partner.id,
|
||||
excluded_ids=[receivable1.id],
|
||||
search_str="deco",
|
||||
mode="rp",
|
||||
)
|
||||
mv_lines_ids = [line["id"] for line in mv_lines_rec]
|
||||
|
||||
self.assertNotIn(receivable1.id, mv_lines_ids)
|
||||
self.assertIn(receivable2.id, mv_lines_ids)
|
||||
|
||||
def test_partner_name_with_parent(self):
|
||||
parent_partner = self.env["res.partner"].create(
|
||||
{
|
||||
"name": "test",
|
||||
}
|
||||
)
|
||||
child_partner = self.env["res.partner"].create(
|
||||
{
|
||||
"name": "test",
|
||||
"parent_id": parent_partner.id,
|
||||
"type": "delivery",
|
||||
}
|
||||
)
|
||||
self.create_invoice_partner(
|
||||
currency_id=self.currency_euro_id, partner_id=child_partner.id
|
||||
)
|
||||
|
||||
bank_stmt = self.acc_bank_stmt_model.create(
|
||||
{
|
||||
"company_id": self.env.ref("base.main_company").id,
|
||||
"journal_id": self.bank_journal_euro.id,
|
||||
"date": time.strftime("%Y-07-15"),
|
||||
"name": "test",
|
||||
}
|
||||
)
|
||||
|
||||
bank_stmt_line = self.acc_bank_stmt_line_model.create(
|
||||
{
|
||||
"name": "testLine",
|
||||
"statement_id": bank_stmt.id,
|
||||
"amount": 100,
|
||||
"date": time.strftime("%Y-07-15"),
|
||||
"payment_ref": "test",
|
||||
"partner_name": "test",
|
||||
}
|
||||
)
|
||||
|
||||
bkstmt_data = self.env[
|
||||
"account.reconciliation.widget"
|
||||
].get_bank_statement_line_data(bank_stmt_line.ids)
|
||||
|
||||
self.assertEqual(len(bkstmt_data["lines"]), 1)
|
||||
self.assertEqual(bkstmt_data["lines"][0]["partner_id"], parent_partner.id)
|
||||
@@ -0,0 +1,25 @@
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<odoo>
|
||||
<data>
|
||||
<record id="view_bank_statement_form" model="ir.ui.view">
|
||||
<field name="name">account.bank.statement.inherit.view.form</field>
|
||||
<field name="model">account.bank.statement</field>
|
||||
<field name="inherit_id" ref="account.view_bank_statement_form" />
|
||||
<field name="arch" type="xml">
|
||||
<xpath expr="//button[@name='button_post']" position="before">
|
||||
<button
|
||||
name="action_bank_reconcile_bank_statements"
|
||||
string="Reconcile"
|
||||
type="object"
|
||||
class="oe_highlight"
|
||||
attrs="{'invisible':['|','|',('all_lines_reconciled','=',True),('line_ids','=',[]),('state', '!=', 'posted')]}"
|
||||
/>
|
||||
</xpath>
|
||||
<xpath expr="//field[@name='date']" position="after">
|
||||
<field name="accounting_date" groups="base.group_no_one" />
|
||||
</xpath>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
</data>
|
||||
</odoo>
|
||||
@@ -0,0 +1,47 @@
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<odoo>
|
||||
<data>
|
||||
<record id="account_journal_dashboard_kanban_view" model="ir.ui.view">
|
||||
<field name="name">account.journal.inherit.dashboard.kanban</field>
|
||||
<field name="model">account.journal</field>
|
||||
<field
|
||||
name="inherit_id"
|
||||
ref="account.account_journal_dashboard_kanban_view"
|
||||
/>
|
||||
<field name="arch" type="xml">
|
||||
<xpath
|
||||
expr="//kanban/templates//div[@id='dashboard_bank_cash_left']/t[1]"
|
||||
position="before"
|
||||
>
|
||||
<t t-if="dashboard.number_to_reconcile > 0">
|
||||
<button
|
||||
type="object"
|
||||
name="action_open_reconcile"
|
||||
class="btn btn-primary"
|
||||
> Reconcile <t
|
||||
t-esc="dashboard.number_to_reconcile"
|
||||
/> Items</button>
|
||||
</t>
|
||||
</xpath>
|
||||
<xpath
|
||||
expr="//kanban/templates//div[@id='dashboard_bank_cash_right']"
|
||||
position="inside"
|
||||
>
|
||||
<t t-if="dashboard.number_to_check > 0">
|
||||
<div class="row">
|
||||
<div class="col overflow-hidden text-left">
|
||||
<a type="object" name="action_open_reconcile_to_check">
|
||||
<t t-esc="dashboard.number_to_check" /> to check</a>
|
||||
</div>
|
||||
<div class="col-auto text-right">
|
||||
<span>
|
||||
<t t-esc="dashboard.to_check_balance" />
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
</t>
|
||||
</xpath>
|
||||
</field>
|
||||
</record>
|
||||
</data>
|
||||
</odoo>
|
||||
30
account_reconciliation_widget/views/account_view.xml
Normal file
30
account_reconciliation_widget/views/account_view.xml
Normal file
@@ -0,0 +1,30 @@
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<odoo>
|
||||
<data>
|
||||
<record id="action_bank_reconcile" model="ir.actions.client">
|
||||
<field name="name">Reconciliation on Bank Statements</field>
|
||||
<field name="res_model">account.bank.statement.line</field>
|
||||
<field name="tag">bank_statement_reconciliation_view</field>
|
||||
</record>
|
||||
|
||||
<record id="action_view_account_move_line_reconcile" model="ir.actions.client">
|
||||
<field name="name">Reconcile</field>
|
||||
<field name="tag">manual_reconciliation_view</field>
|
||||
<field name="binding_model_id" ref="account.model_account_move_line" />
|
||||
<field name="binding_type">action</field>
|
||||
<field name="binding_view_types">list</field>
|
||||
</record>
|
||||
|
||||
<record id="action_manual_reconciliation" model="ir.actions.client">
|
||||
<field name="name">Reconciliation</field>
|
||||
<field name="tag">manual_reconciliation_view</field>
|
||||
</record>
|
||||
|
||||
<menuitem
|
||||
id="menu_action_manual_reconciliation"
|
||||
parent="account.menu_finance_entries_actions"
|
||||
action="action_manual_reconciliation"
|
||||
sequence="25"
|
||||
/>
|
||||
</data>
|
||||
</odoo>
|
||||
42
account_reconciliation_widget/views/assets.xml
Normal file
42
account_reconciliation_widget/views/assets.xml
Normal file
@@ -0,0 +1,42 @@
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<odoo>
|
||||
<template
|
||||
id="assets_backend"
|
||||
name="account_reconciliation_widget assets"
|
||||
inherit_id="web.assets_backend"
|
||||
>
|
||||
<xpath expr="." position="inside">
|
||||
|
||||
<link
|
||||
rel="stylesheet"
|
||||
type="text/scss"
|
||||
href="/account_reconciliation_widget/static/src/scss/account_reconciliation.scss"
|
||||
/>
|
||||
|
||||
<script
|
||||
type="text/javascript"
|
||||
src="/account_reconciliation_widget/static/src/js/reconciliation/reconciliation_action.js"
|
||||
/>
|
||||
<script
|
||||
type="text/javascript"
|
||||
src="/account_reconciliation_widget/static/src/js/reconciliation/reconciliation_model.js"
|
||||
/>
|
||||
<script
|
||||
type="text/javascript"
|
||||
src="/account_reconciliation_widget/static/src/js/reconciliation/reconciliation_renderer.js"
|
||||
/>
|
||||
|
||||
</xpath>
|
||||
</template>
|
||||
|
||||
<template id="qunit_suite" name="account tests" inherit_id="web.qunit_suite_tests">
|
||||
<xpath expr="." position="inside">
|
||||
|
||||
<script
|
||||
type="text/javascript"
|
||||
src="/account_reconciliation_widget/static/tests/account_reconciliation_tests.js"
|
||||
/>
|
||||
|
||||
</xpath>
|
||||
</template>
|
||||
</odoo>
|
||||
@@ -0,0 +1 @@
|
||||
../../../../account_reconciliation_widget
|
||||
6
setup/account_reconciliation_widget/setup.py
Normal file
6
setup/account_reconciliation_widget/setup.py
Normal file
@@ -0,0 +1,6 @@
|
||||
import setuptools
|
||||
|
||||
setuptools.setup(
|
||||
setup_requires=['setuptools-odoo'],
|
||||
odoo_addon=True,
|
||||
)
|
||||
Reference in New Issue
Block a user