Skip to content

Commit

Permalink
[IMP] account_reconcile_oca: Apply OCA updates
Browse files Browse the repository at this point in the history
  • Loading branch information
rinaldifirdaus committed Sep 15, 2023
1 parent b654fb8 commit fd175e2
Show file tree
Hide file tree
Showing 9 changed files with 110 additions and 39 deletions.
2 changes: 1 addition & 1 deletion account_reconcile_oca/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Account Reconcile Oca
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:9dd741145a7d3454af97f97eb432cc4bb1718e9b9d0cef6ec314887e2fb25296
!! source digest: sha256:fb0fd744eefd0185149b04302d378a12ae62c7db864b2230c6d71149eda92e79
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
Expand Down
2 changes: 1 addition & 1 deletion account_reconcile_oca/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"name": "Account Reconcile Oca",
"summary": """
Reconcile addons for Odoo CE accounting""",
"version": "16.0.1.1.0",
"version": "16.0.1.2.2",
"license": "AGPL-3",
"author": "CreuBlanca,Odoo Community Association (OCA)",
"maintainers": ["etobella"],
Expand Down
18 changes: 16 additions & 2 deletions account_reconcile_oca/i18n/account_reconcile_oca.pot
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,6 @@ msgstr ""

#. module: account_reconcile_oca
#: model_terms:ir.ui.view,arch_db:account_reconcile_oca.account_account_reconcile_form_view
#: model_terms:ir.ui.view,arch_db:account_reconcile_oca.bank_statement_line_form_reconcile_view
msgid "Clean"
msgstr ""

Expand Down Expand Up @@ -298,6 +297,11 @@ msgstr ""
msgid "Manual Amount"
msgstr ""

#. module: account_reconcile_oca
#: model:ir.model.fields,field_description:account_reconcile_oca.field_account_bank_statement_line__manual_currency_id
msgid "Manual Currency"
msgstr ""

#. module: account_reconcile_oca
#: model:ir.model.fields,field_description:account_reconcile_oca.field_account_account_reconcile__manual_delete
#: model:ir.model.fields,field_description:account_reconcile_oca.field_account_bank_statement_line__manual_delete
Expand Down Expand Up @@ -368,6 +372,11 @@ msgstr ""
msgid "Name"
msgstr ""

#. module: account_reconcile_oca
#: model_terms:ir.ui.view,arch_db:account_reconcile_oca.bank_statement_line_form_reconcile_view
msgid "Narration"
msgstr ""

#. module: account_reconcile_oca
#. odoo-python
#: code:addons/account_reconcile_oca/models/account_bank_statement_line.py:0
Expand Down Expand Up @@ -462,7 +471,7 @@ msgstr ""

#. module: account_reconcile_oca
#: model_terms:ir.ui.view,arch_db:account_reconcile_oca.bank_statement_line_form_reconcile_view
msgid "Reset"
msgid "Reset reconciliation"
msgstr ""

#. module: account_reconcile_oca
Expand Down Expand Up @@ -512,6 +521,11 @@ msgstr ""
msgid "Undefined"
msgstr ""

#. module: account_reconcile_oca
#: model_terms:ir.ui.view,arch_db:account_reconcile_oca.bank_statement_line_form_reconcile_view
msgid "Unreconcile"
msgstr ""

#. module: account_reconcile_oca
#: model:ir.model.fields,field_description:account_reconcile_oca.field_account_account_reconcile_data__user_id
msgid "User"
Expand Down
19 changes: 19 additions & 0 deletions account_reconcile_oca/migrations/16.0.1.2.0/pre-migration.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
from openupgradelib import openupgrade


@openupgrade.migrate()
def migrate(env, version):
# Due to the big change we did, we need to loose how data is stored
openupgrade.logged_query(
env.cr,
"""
UPDATE account_bank_statement_line
SET reconcile_data = NULL
""",
)
openupgrade.logged_query(
env.cr,
"""
DELETE FROM account_account_reconcile_data
""",
)
79 changes: 50 additions & 29 deletions account_reconcile_oca/models/account_bank_statement_line.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,12 @@ class AccountBankStatementLine(models.Model):
domain=[("rule_type", "=", "writeoff_button")],
)
manual_name = fields.Char(store=False, default=False, prefetch=False)
manual_amount = fields.Monetary(store=False, default=False, prefetch=False)
manual_amount = fields.Monetary(
store=False, default=False, prefetch=False, currency_field="manual_currency_id"
)
manual_currency_id = fields.Many2one(
"res.currency", readonly=True, store=False, prefetch=False
)
manual_original_amount = fields.Monetary(
default=False, store=False, prefetch=False, readonly=True
)
Expand Down Expand Up @@ -240,13 +245,15 @@ def _onchange_manual_reconcile_reference(self):
"manual_move_type": False,
"manual_kind": False,
"manual_original_amount": False,
"manual_currency_id": False,
"analytic_distribution": False,
}
)
continue
else:
self.manual_account_id = line["account_id"][0]
self.manual_amount = line["amount"]
self.manual_currency_id = line["currency_id"]
self.manual_name = line["name"]
self.manual_partner_id = (
line.get("partner_id") and line["partner_id"][0]
Expand Down Expand Up @@ -323,7 +330,9 @@ def _compute_reconcile_data_info(self):
if record.reconcile_data:
record.reconcile_data_info = record.reconcile_data
else:
record.reconcile_data_info = record._default_reconcile_data()
record.reconcile_data_info = record._default_reconcile_data(
from_unreconcile=record.is_reconciled
)
record.can_reconcile = record.reconcile_data_info.get(
"can_reconcile", False
)
Expand Down Expand Up @@ -418,35 +427,44 @@ def _compute_exchange_rate(self, data, reconcile_auxiliary_id):
reconcile_auxiliary_id += 1
return reconcile_auxiliary_id

def _default_reconcile_data(self):
def _default_reconcile_data(self, from_unreconcile=False):
liquidity_lines, suspense_lines, other_lines = self._seek_for_lines()
data = [self._get_reconcile_line(line, "liquidity") for line in liquidity_lines]
reconcile_auxiliary_id = 1
res = (
self.env["account.reconcile.model"]
.search([("rule_type", "in", ["invoice_matching", "writeoff_suggestion"])])
._apply_rules(self, self._retrieve_partner())
)
if res and res.get("status", "") == "write_off":
return self._recompute_suspense_line(
*self._reconcile_data_by_model(
data, res["model"], reconcile_auxiliary_id
),
self.manual_reference
)
elif res and res.get("amls"):
amount = self.amount_total_signed
for line in res.get("amls", []):
line_data = self._get_reconcile_line(
line, "other", is_counterpart=True, max_amount=amount
if not from_unreconcile:
res = (
self.env["account.reconcile.model"]
.search(
[("rule_type", "in", ["invoice_matching", "writeoff_suggestion"])]
)
amount -= line_data.get("amount")
data.append(line_data)
return self._recompute_suspense_line(
data, reconcile_auxiliary_id, self.manual_reference
._apply_rules(self, self._retrieve_partner())
)
if res and res.get("status", "") == "write_off":
return self._recompute_suspense_line(
*self._reconcile_data_by_model(
data, res["model"], reconcile_auxiliary_id
),
self.manual_reference
)
elif res and res.get("amls"):
amount = self.amount_total_signed
for line in res.get("amls", []):
line_data = self._get_reconcile_line(
line, "other", is_counterpart=True, max_amount=amount
)
amount -= line_data.get("amount")
data.append(line_data)
return self._recompute_suspense_line(
data, reconcile_auxiliary_id, self.manual_reference
)
return self._recompute_suspense_line(
data + [self._get_reconcile_line(line, "other") for line in other_lines],
data
+ [
self._get_reconcile_line(
line, "other", from_unreconcile=from_unreconcile
)
for line in other_lines
],
reconcile_auxiliary_id,
self.manual_reference,
)
Expand All @@ -458,9 +476,11 @@ def clean_reconcile(self):
def reconcile_bank_line(self):
self.ensure_one()
self.reconcile_mode = self.journal_id.reconcile_mode
return getattr(self, "_reconcile_bank_line_%s" % self.reconcile_mode)(
result = getattr(self, "_reconcile_bank_line_%s" % self.reconcile_mode)(
self.reconcile_data_info["data"]
)
self.reconcile_data_info = False
return result

def _reconcile_bank_line_edit(self, data):
_liquidity_lines, suspense_lines, other_lines = self._seek_for_lines()
Expand Down Expand Up @@ -574,12 +594,13 @@ def unreconcile_bank_line(self):
self.ensure_one()
return getattr(
self, "_unreconcile_bank_line_%s" % (self.reconcile_mode or "edit")
)(self.reconcile_data_info["data"])
)()

def _unreconcile_bank_line_edit(self, data):
def _unreconcile_bank_line_edit(self):
self.reconcile_data_info = self._default_reconcile_data(from_unreconcile=True)
self.action_undo_reconciliation()

def _unreconcile_bank_line_keep(self, data):
def _unreconcile_bank_line_keep(self):
raise UserError(_("Keep suspense move lines mode cannot be unreconciled"))

def _reconcile_move_line_vals(self, line, move_id=False):
Expand Down
14 changes: 13 additions & 1 deletion account_reconcile_oca/models/account_reconcile_abstract.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,9 @@ class AccountReconcileAbstract(models.AbstractModel):
"res.currency", related="company_id.currency_id"
)

def _get_reconcile_line(self, line, kind, is_counterpart=False, max_amount=False):
def _get_reconcile_line(
self, line, kind, is_counterpart=False, max_amount=False, from_unreconcile=False
):
date = self.date if "date" in self._fields else line.date
original_amount = amount = net_amount = line.debit - line.credit
amount_currency = self.company_id.currency_id
Expand Down Expand Up @@ -80,6 +82,16 @@ def _get_reconcile_line(self, line, kind, is_counterpart=False, max_amount=False
"analytic_distribution": line.analytic_distribution,
"kind": kind,
}
if from_unreconcile:
vals.update(
{
"id": False,
"counterpart_line_id": (
line.matched_debit_ids.mapped("debit_move_id")
| line.matched_credit_ids.mapped("credit_move_id")
).id,
}
)
if not float_is_zero(
amount - original_amount, precision_digits=line.currency_id.decimal_places
):
Expand Down
2 changes: 1 addition & 1 deletion account_reconcile_oca/static/description/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,7 @@ <h1 class="title">Account Reconcile Oca</h1>
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:9dd741145a7d3454af97f97eb432cc4bb1718e9b9d0cef6ec314887e2fb25296
!! source digest: sha256:fb0fd744eefd0185149b04302d378a12ae62c7db864b2230c6d71149eda92e79
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
<p><a class="reference external image-reference" 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 image-reference" 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 image-reference" href="https://github.com/OCA/account-reconcile/tree/16.0/account_reconcile_oca"><img alt="OCA/account-reconcile" src="https://img.shields.io/badge/github-OCA%2Faccount--reconcile-lightgray.png?logo=github" /></a> <a class="reference external image-reference" href="https://translation.odoo-community.org/projects/account-reconcile-16-0/account-reconcile-16-0-account_reconcile_oca"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external image-reference" href="https://runboat.odoo-community.org/builds?repo=OCA/account-reconcile&amp;target_branch=16.0"><img alt="Try me on Runboat" src="https://img.shields.io/badge/runboat-Try%20me-875A7B.png" /></a></p>
<p>This addon allows to reconcile bank statements and account marked as <cite>reconcile</cite>.</p>
Expand Down
4 changes: 2 additions & 2 deletions account_reconcile_oca/static/src/xml/reconcile.xml
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@
</th>
<th class="text-end">Debit</th>
<th class="text-end">Credit</th>
<th />
<th t-if="! props.record.data.is_reconciled" />
</thead>
<tbody>
<t
Expand Down Expand Up @@ -130,7 +130,7 @@
class="btn fa fa-trash-o"
role="button"
t-on-click="(ev) => this.onTrashLine(ev, reconcile_line)"
t-if="reconcile_line.kind == 'other'"
t-if="reconcile_line.kind == 'other' &amp;&amp; ! props.record.data.is_reconciled"
/>
</td>
</tr>
Expand Down
9 changes: 7 additions & 2 deletions account_reconcile_oca/views/account_bank_statement_line.xml
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@
<button
name="unreconcile_bank_line"
type="object"
string="Reset"
string="Unreconcile"
accesskey="r"
class="btn btn-warning"
attrs="{'invisible': [('is_reconciled', '=', False)]}"
Expand All @@ -152,7 +152,7 @@
<button
name="clean_reconcile"
type="object"
string="Clean"
string="Reset reconciliation"
class="btn btn-secondary"
attrs="{'invisible': [('is_reconciled', '=', True)]}"
/>
Expand Down Expand Up @@ -255,6 +255,7 @@
string="Amount"
attrs="{'readonly': ['|', ('manual_reference', '=', False), ('is_reconciled', '=', True)]}"
/>
<field name="manual_currency_id" invisible="1" />
<field name="manual_original_amount" invisible="1" />
<field name="manual_move_type" invisible="1" />
<label
Expand Down Expand Up @@ -287,6 +288,10 @@
</group>
</group>
</page>
<page name="narration" string="Narration">
<field name="payment_ref" />
<field name="narration" />
</page>
<page name="chatter" string="Chatter">
<field name="move_id" widget="account_reconcile_oca_chatter" />
</page>
Expand Down

0 comments on commit fd175e2

Please sign in to comment.