diff --git a/account_reconciliation_widget/__manifest__.py b/account_reconciliation_widget/__manifest__.py
index 33bf216c..b2384249 100644
--- a/account_reconciliation_widget/__manifest__.py
+++ b/account_reconciliation_widget/__manifest__.py
@@ -3,7 +3,7 @@
{
"name": "account_reconciliation_widget",
- "version": "14.0.1.2.0",
+ "version": "15.0.1.1.1",
"category": "Accounting",
"license": "AGPL-3",
"summary": "Account reconciliation widget",
@@ -12,13 +12,21 @@
"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",
- ],
+ "assets": {
+ "web.assets_backend": [
+ "account_reconciliation_widget/static/src/scss/account_reconciliation.scss",
+ "account_reconciliation_widget/static/src/js/reconciliation**/*",
+ ],
+ "web.qunit_suite_tests": [
+ "account_reconciliation_widget/static/tests/**/*",
+ ],
+ "web.assets_qweb": [
+ "account_reconciliation_widget/static/src/xml/account_reconciliation.xml",
+ ],
+ },
"installable": True,
}
diff --git a/account_reconciliation_widget/models/account_bank_statement.py b/account_reconciliation_widget/models/account_bank_statement.py
index 1a942e12..e27203dc 100644
--- a/account_reconciliation_widget/models/account_bank_statement.py
+++ b/account_reconciliation_widget/models/account_bank_statement.py
@@ -7,7 +7,7 @@ class AccountBankStatement(models.Model):
_inherit = "account.bank.statement"
accounting_date = fields.Date(
- string="Accounting Date",
+ string="Financial Date",
help="If set, the accounting entries created during the bank statement "
"reconciliation process will be created at this date.\n"
"This is useful if the accounting period in which the entries should "
@@ -33,15 +33,14 @@ class AccountBankStatementLine(models.Model):
_inherit = "account.bank.statement.line"
- # FIXME: is this necessary now?
move_name = fields.Char(
string="Journal Entry Name",
readonly=True,
default=False,
copy=False,
- help="Technical field holding the number given to the journal entry, "
- "automatically set when the statement line is reconciled then "
- "stored to set the same number again if the line is cancelled, "
+ help="Technical field holding the number given to the journal entry,"
+ "automatically set when the statement line is reconciled then stored"
+ "to set the same number again if the line is cancelled,"
"set to draft and re-processed again.",
)
@@ -130,27 +129,9 @@ class AccountBankStatementLine(models.Model):
and user_type_id not in account_types
):
account_types |= user_type_id
- # 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
- currency = self.foreign_currency_id or statement_currency
+ currency = self.currency_id or statement_currency
for aml_rec in payment_aml_rec:
balance = (
aml_rec.amount_currency if aml_rec.currency_id else aml_rec.balance
@@ -163,11 +144,8 @@ class AccountBankStatementLine(models.Model):
{"statement_line_id": self.id}
)
counterpart_moves = counterpart_moves | aml_rec.move_id
- if (
- aml_rec.journal_id.post_at == "bank_rec"
- and aml_rec.payment_id
- and aml_rec.move_id.state == "draft"
- ):
+ # Update
+ if aml_rec.payment_id and aml_rec.move_id.state == "draft":
# In case the journal is set to only post payments when
# performing bank reconciliation, we modify its date and post
# it.
@@ -180,8 +158,8 @@ class AccountBankStatementLine(models.Model):
self._check_invoice_state(invoice)
# Create move line(s). Either matching an existing journal entry
- # (eg. invoice), in which case we reconcile the existing and the new
- # move lines together, or being a write-off.
+ # (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:
counterpart_moves = self._create_counterpart_and_new_aml(
counterpart_moves, counterpart_aml_dicts, new_aml_dicts
@@ -200,9 +178,9 @@ class AccountBankStatementLine(models.Model):
)
# create the res.partner.bank if needed
- if self.account_number and self.partner_id and not self.partner_bank_id:
- # Search bank account without partner to handle the case the
- # res.partner.bank already exists but is set on a different partner.
+ 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.partner_bank_id = self._find_or_create_bank_account()
counterpart_moves._check_balanced()
@@ -252,7 +230,7 @@ class AccountBankStatementLine(models.Model):
aml_to_reconcile.append((new_aml, counterpart_move_line))
# Post to allow reconcile
- if self.move_id.state != "posted":
+ if self.move_id.state == "draft":
self.move_id.with_context(
skip_account_move_synchronization=True
).action_post()
@@ -264,7 +242,10 @@ class AccountBankStatementLine(models.Model):
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()
+ if self.move_id.state == "draft":
+ 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})
@@ -275,9 +256,9 @@ class AccountBankStatementLine(models.Model):
self.ensure_one()
company_currency = self.journal_id.company_id.currency_id
statement_currency = self.journal_id.currency_id or company_currency
- st_line_currency = self.foreign_currency_id or statement_currency
+ st_line_currency = self.currency_id or statement_currency
st_line_currency_rate = (
- self.foreign_currency_id and (self.amount_currency / self.amount) or False
+ self.currency_id and (self.amount_currency / self.amount) or False
)
company = self.company_id
@@ -285,21 +266,19 @@ class AccountBankStatementLine(models.Model):
aml_dict["amount_currency"] = aml_dict["debit"] - aml_dict["credit"]
aml_dict["currency_id"] = st_line_currency.id
if (
- self.foreign_currency_id
+ self.currency_id
and statement_currency.id == company_currency.id
and st_line_currency_rate
):
- # Statement is in company currency but the transaction is in
- # foreign currency
+ # Statement is in company currency but the transaction is in foreign currency
aml_dict["debit"] = company_currency.round(
aml_dict["debit"] / st_line_currency_rate
)
aml_dict["credit"] = company_currency.round(
aml_dict["credit"] / st_line_currency_rate
)
- elif self.foreign_currency_id and st_line_currency_rate:
- # Statement is in foreign currency and the transaction is in
- # another one
+ elif self.currency_id and st_line_currency_rate:
+ # Statement is in foreign currency and the transaction is in another one
aml_dict["debit"] = statement_currency._convert(
aml_dict["debit"] / st_line_currency_rate,
company_currency,
@@ -313,8 +292,8 @@ class AccountBankStatementLine(models.Model):
date,
)
else:
- # Statement is in foreign currency and no extra currency is
- # given for the transaction
+ # Statement is in foreign currency and no extra currency is given
+ # for the transaction
aml_dict["debit"] = st_line_currency._convert(
aml_dict["debit"], company_currency, company, date
)
@@ -322,8 +301,7 @@ class AccountBankStatementLine(models.Model):
aml_dict["credit"], company_currency, company, date
)
elif statement_currency.id != company_currency.id:
- # Statement is in foreign currency but the transaction is in company
- # currency
+ # Statement is in foreign currency but the transaction is in company currency
prorata_factor = (
aml_dict["debit"] - aml_dict["credit"]
) / self.amount_currency
diff --git a/account_reconciliation_widget/models/reconciliation_widget.py b/account_reconciliation_widget/models/reconciliation_widget.py
index 105de0ea..c049934b 100644
--- a/account_reconciliation_widget/models/reconciliation_widget.py
+++ b/account_reconciliation_widget/models/reconciliation_widget.py
@@ -1,4 +1,5 @@
import copy
+import logging
from psycopg2 import sql
@@ -7,6 +8,8 @@ from odoo.exceptions import UserError
from odoo.osv import expression
from odoo.tools.misc import format_date, formatLang, parse_date
+_logger = logging.getLogger(__name__)
+
class AccountReconciliation(models.AbstractModel):
_name = "account.reconciliation.widget"
@@ -46,7 +49,7 @@ class AccountReconciliation(models.AbstractModel):
st_line.write({"partner_id": datum["partner_id"]})
ctx["default_to_check"] = datum.get("to_check")
- moves = st_line.with_context(ctx).process_reconciliation(
+ moves = st_line.with_context(**ctx).process_reconciliation(
datum.get("counterpart_aml_dicts", []),
payment_aml_rec,
datum.get("new_aml_dicts", []),
@@ -135,7 +138,7 @@ class AccountReconciliation(models.AbstractModel):
recs_count = 0
aml_recs = self.env["account.move.line"].browse([i[0] for i in res])
target_currency = (
- st_line.foreign_currency_id
+ st_line.currency_id
or st_line.journal_id.currency_id
or st_line.journal_id.company_id.currency_id
)
@@ -157,9 +160,7 @@ class AccountReconciliation(models.AbstractModel):
self.env["res.partner.bank"]._apply_ir_rules(ir_rules_query, "read")
from_clause, where_clause, where_clause_params = ir_rules_query.get_sql()
if where_clause:
- where_bank = ("AND %s" % where_clause).replace(
- '"res_partner_bank"', '"bank"'
- )
+ where_bank = ("AND %s" % where_clause).replace("res_partner_bank", "bank")
params += where_clause_params
else:
where_bank = ""
@@ -171,7 +172,7 @@ class AccountReconciliation(models.AbstractModel):
self.env["res.partner"]._apply_ir_rules(ir_rules_query, "read")
from_clause, where_clause, where_clause_params = ir_rules_query.get_sql()
if where_clause:
- where_partner = ("AND %s" % where_clause).replace('"res_partner"', '"p3"')
+ where_partner = ("AND %s" % where_clause).replace("res_partner", "p3")
params += where_clause_params
else:
where_partner = ""
@@ -257,7 +258,7 @@ class AccountReconciliation(models.AbstractModel):
aml_ids = matching_amls[line.id]["aml_ids"]
bank_statements_left += line.statement_id
target_currency = (
- line.foreign_currency_id
+ line.currency_id
or line.journal_id.currency_id
or line.journal_id.company_id.currency_id
)
@@ -710,7 +711,7 @@ class AccountReconciliation(models.AbstractModel):
]
str_domain = expression.OR([str_domain, amount_domain])
except Exception:
- pass
+ _logger.warning(Exception)
else:
try:
amount = float(search_str)
@@ -735,7 +736,7 @@ class AccountReconciliation(models.AbstractModel):
]
str_domain = expression.OR([str_domain, amount_domain])
except Exception:
- pass
+ _logger.warning(Exception)
return str_domain
@api.model
@@ -1021,7 +1022,7 @@ class AccountReconciliation(models.AbstractModel):
statement_currency = (
st_line.journal_id.currency_id or st_line.journal_id.company_id.currency_id
)
- if st_line.amount_currency and st_line.foreign_currency_id:
+ if st_line.amount_currency and st_line.currency_id:
amount = st_line.amount_currency
amount_currency = st_line.amount
amount_currency_str = formatLang(
@@ -1034,7 +1035,7 @@ class AccountReconciliation(models.AbstractModel):
amount_str = formatLang(
self.env,
abs(amount),
- currency_obj=st_line.foreign_currency_id or statement_currency,
+ currency_obj=st_line.currency_id or statement_currency,
)
data = {
@@ -1046,7 +1047,7 @@ class AccountReconciliation(models.AbstractModel):
"date": format_date(self.env, st_line.date),
"amount": amount,
"amount_str": amount_str, # Amount in the statement line currency
- "currency_id": st_line.foreign_currency_id.id or statement_currency.id,
+ "currency_id": st_line.currency_id.id or statement_currency.id,
"partner_id": st_line.partner_id.id,
"journal_id": st_line.journal_id.id,
"statement_id": st_line.statement_id.id,
diff --git a/account_reconciliation_widget/static/description/index.html b/account_reconciliation_widget/static/description/index.html
index 3668040e..585dbd33 100644
--- a/account_reconciliation_widget/static/description/index.html
+++ b/account_reconciliation_widget/static/description/index.html
@@ -367,8 +367,8 @@ ul.auto-toc {
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
-
-
This module restores account reconciliation widget moved from Odoo community to enterpise in V. 14.0
+
+
This module restores account reconciliation widget moved from Odoo community to enterpise in V. 15.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
@@ -396,7 +396,7 @@ Provides two widgets designed to reconcile move lines in a easy way: one focused
Bugs are tracked on GitHub Issues.
In case of trouble, please check there if your issue has already been reported.
If you spotted it first, help us smashing it by providing a detailed and welcomed
-feedback.
@@ -421,7 +422,7 @@ If you spotted it first, help us smashing it by providing a detailed and welcome
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.