Skip to content

Commit e6b2131

Browse files
rinaldifirdausyostashiro
authored andcommitted
[IMP] account_reconcile_oca: Apply OCA updates
1 parent 2ff6d55 commit e6b2131

9 files changed

Lines changed: 110 additions & 39 deletions

File tree

account_reconcile_oca/README.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ Account Reconcile Oca
77
!! This file is generated by oca-gen-addon-readme !!
88
!! changes will be overwritten. !!
99
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
10-
!! source digest: sha256:9dd741145a7d3454af97f97eb432cc4bb1718e9b9d0cef6ec314887e2fb25296
10+
!! source digest: sha256:fb0fd744eefd0185149b04302d378a12ae62c7db864b2230c6d71149eda92e79
1111
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
1212
1313
.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png

account_reconcile_oca/__manifest__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"name": "Account Reconcile Oca",
66
"summary": """
77
Reconcile addons for Odoo CE accounting""",
8-
"version": "16.0.1.1.0",
8+
"version": "16.0.1.2.2",
99
"license": "AGPL-3",
1010
"author": "CreuBlanca,Odoo Community Association (OCA)",
1111
"maintainers": ["etobella"],

account_reconcile_oca/i18n/account_reconcile_oca.pot

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,6 @@ msgstr ""
116116

117117
#. module: account_reconcile_oca
118118
#: model_terms:ir.ui.view,arch_db:account_reconcile_oca.account_account_reconcile_form_view
119-
#: model_terms:ir.ui.view,arch_db:account_reconcile_oca.bank_statement_line_form_reconcile_view
120119
msgid "Clean"
121120
msgstr ""
122121

@@ -298,6 +297,11 @@ msgstr ""
298297
msgid "Manual Amount"
299298
msgstr ""
300299

300+
#. module: account_reconcile_oca
301+
#: model:ir.model.fields,field_description:account_reconcile_oca.field_account_bank_statement_line__manual_currency_id
302+
msgid "Manual Currency"
303+
msgstr ""
304+
301305
#. module: account_reconcile_oca
302306
#: model:ir.model.fields,field_description:account_reconcile_oca.field_account_account_reconcile__manual_delete
303307
#: model:ir.model.fields,field_description:account_reconcile_oca.field_account_bank_statement_line__manual_delete
@@ -368,6 +372,11 @@ msgstr ""
368372
msgid "Name"
369373
msgstr ""
370374

375+
#. module: account_reconcile_oca
376+
#: model_terms:ir.ui.view,arch_db:account_reconcile_oca.bank_statement_line_form_reconcile_view
377+
msgid "Narration"
378+
msgstr ""
379+
371380
#. module: account_reconcile_oca
372381
#. odoo-python
373382
#: code:addons/account_reconcile_oca/models/account_bank_statement_line.py:0
@@ -462,7 +471,7 @@ msgstr ""
462471

463472
#. module: account_reconcile_oca
464473
#: model_terms:ir.ui.view,arch_db:account_reconcile_oca.bank_statement_line_form_reconcile_view
465-
msgid "Reset"
474+
msgid "Reset reconciliation"
466475
msgstr ""
467476

468477
#. module: account_reconcile_oca
@@ -512,6 +521,11 @@ msgstr ""
512521
msgid "Undefined"
513522
msgstr ""
514523

524+
#. module: account_reconcile_oca
525+
#: model_terms:ir.ui.view,arch_db:account_reconcile_oca.bank_statement_line_form_reconcile_view
526+
msgid "Unreconcile"
527+
msgstr ""
528+
515529
#. module: account_reconcile_oca
516530
#: model:ir.model.fields,field_description:account_reconcile_oca.field_account_account_reconcile_data__user_id
517531
msgid "User"
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
from openupgradelib import openupgrade
2+
3+
4+
@openupgrade.migrate()
5+
def migrate(env, version):
6+
# Due to the big change we did, we need to loose how data is stored
7+
openupgrade.logged_query(
8+
env.cr,
9+
"""
10+
UPDATE account_bank_statement_line
11+
SET reconcile_data = NULL
12+
""",
13+
)
14+
openupgrade.logged_query(
15+
env.cr,
16+
"""
17+
DELETE FROM account_account_reconcile_data
18+
""",
19+
)

account_reconcile_oca/models/account_bank_statement_line.py

Lines changed: 50 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,12 @@ class AccountBankStatementLine(models.Model):
6666
domain=[("rule_type", "=", "writeoff_button")],
6767
)
6868
manual_name = fields.Char(store=False, default=False, prefetch=False)
69-
manual_amount = fields.Monetary(store=False, default=False, prefetch=False)
69+
manual_amount = fields.Monetary(
70+
store=False, default=False, prefetch=False, currency_field="manual_currency_id"
71+
)
72+
manual_currency_id = fields.Many2one(
73+
"res.currency", readonly=True, store=False, prefetch=False
74+
)
7075
manual_original_amount = fields.Monetary(
7176
default=False, store=False, prefetch=False, readonly=True
7277
)
@@ -240,13 +245,15 @@ def _onchange_manual_reconcile_reference(self):
240245
"manual_move_type": False,
241246
"manual_kind": False,
242247
"manual_original_amount": False,
248+
"manual_currency_id": False,
243249
"analytic_distribution": False,
244250
}
245251
)
246252
continue
247253
else:
248254
self.manual_account_id = line["account_id"][0]
249255
self.manual_amount = line["amount"]
256+
self.manual_currency_id = line["currency_id"]
250257
self.manual_name = line["name"]
251258
self.manual_partner_id = (
252259
line.get("partner_id") and line["partner_id"][0]
@@ -323,7 +330,9 @@ def _compute_reconcile_data_info(self):
323330
if record.reconcile_data:
324331
record.reconcile_data_info = record.reconcile_data
325332
else:
326-
record.reconcile_data_info = record._default_reconcile_data()
333+
record.reconcile_data_info = record._default_reconcile_data(
334+
from_unreconcile=record.is_reconciled
335+
)
327336
record.can_reconcile = record.reconcile_data_info.get(
328337
"can_reconcile", False
329338
)
@@ -418,35 +427,44 @@ def _compute_exchange_rate(self, data, reconcile_auxiliary_id):
418427
reconcile_auxiliary_id += 1
419428
return reconcile_auxiliary_id
420429

421-
def _default_reconcile_data(self):
430+
def _default_reconcile_data(self, from_unreconcile=False):
422431
liquidity_lines, suspense_lines, other_lines = self._seek_for_lines()
423432
data = [self._get_reconcile_line(line, "liquidity") for line in liquidity_lines]
424433
reconcile_auxiliary_id = 1
425-
res = (
426-
self.env["account.reconcile.model"]
427-
.search([("rule_type", "in", ["invoice_matching", "writeoff_suggestion"])])
428-
._apply_rules(self, self._retrieve_partner())
429-
)
430-
if res and res.get("status", "") == "write_off":
431-
return self._recompute_suspense_line(
432-
*self._reconcile_data_by_model(
433-
data, res["model"], reconcile_auxiliary_id
434-
),
435-
self.manual_reference
436-
)
437-
elif res and res.get("amls"):
438-
amount = self.amount_total_signed
439-
for line in res.get("amls", []):
440-
line_data = self._get_reconcile_line(
441-
line, "other", is_counterpart=True, max_amount=amount
434+
if not from_unreconcile:
435+
res = (
436+
self.env["account.reconcile.model"]
437+
.search(
438+
[("rule_type", "in", ["invoice_matching", "writeoff_suggestion"])]
442439
)
443-
amount -= line_data.get("amount")
444-
data.append(line_data)
445-
return self._recompute_suspense_line(
446-
data, reconcile_auxiliary_id, self.manual_reference
440+
._apply_rules(self, self._retrieve_partner())
447441
)
442+
if res and res.get("status", "") == "write_off":
443+
return self._recompute_suspense_line(
444+
*self._reconcile_data_by_model(
445+
data, res["model"], reconcile_auxiliary_id
446+
),
447+
self.manual_reference
448+
)
449+
elif res and res.get("amls"):
450+
amount = self.amount_total_signed
451+
for line in res.get("amls", []):
452+
line_data = self._get_reconcile_line(
453+
line, "other", is_counterpart=True, max_amount=amount
454+
)
455+
amount -= line_data.get("amount")
456+
data.append(line_data)
457+
return self._recompute_suspense_line(
458+
data, reconcile_auxiliary_id, self.manual_reference
459+
)
448460
return self._recompute_suspense_line(
449-
data + [self._get_reconcile_line(line, "other") for line in other_lines],
461+
data
462+
+ [
463+
self._get_reconcile_line(
464+
line, "other", from_unreconcile=from_unreconcile
465+
)
466+
for line in other_lines
467+
],
450468
reconcile_auxiliary_id,
451469
self.manual_reference,
452470
)
@@ -458,9 +476,11 @@ def clean_reconcile(self):
458476
def reconcile_bank_line(self):
459477
self.ensure_one()
460478
self.reconcile_mode = self.journal_id.reconcile_mode
461-
return getattr(self, "_reconcile_bank_line_%s" % self.reconcile_mode)(
479+
result = getattr(self, "_reconcile_bank_line_%s" % self.reconcile_mode)(
462480
self.reconcile_data_info["data"]
463481
)
482+
self.reconcile_data_info = False
483+
return result
464484

465485
def _reconcile_bank_line_edit(self, data):
466486
_liquidity_lines, suspense_lines, other_lines = self._seek_for_lines()
@@ -574,12 +594,13 @@ def unreconcile_bank_line(self):
574594
self.ensure_one()
575595
return getattr(
576596
self, "_unreconcile_bank_line_%s" % (self.reconcile_mode or "edit")
577-
)(self.reconcile_data_info["data"])
597+
)()
578598

579-
def _unreconcile_bank_line_edit(self, data):
599+
def _unreconcile_bank_line_edit(self):
600+
self.reconcile_data_info = self._default_reconcile_data(from_unreconcile=True)
580601
self.action_undo_reconciliation()
581602

582-
def _unreconcile_bank_line_keep(self, data):
603+
def _unreconcile_bank_line_keep(self):
583604
raise UserError(_("Keep suspense move lines mode cannot be unreconciled"))
584605

585606
def _reconcile_move_line_vals(self, line, move_id=False):

account_reconcile_oca/models/account_reconcile_abstract.py

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,9 @@ class AccountReconcileAbstract(models.AbstractModel):
3333
"res.currency", related="company_id.currency_id"
3434
)
3535

36-
def _get_reconcile_line(self, line, kind, is_counterpart=False, max_amount=False):
36+
def _get_reconcile_line(
37+
self, line, kind, is_counterpart=False, max_amount=False, from_unreconcile=False
38+
):
3739
date = self.date if "date" in self._fields else line.date
3840
original_amount = amount = net_amount = line.debit - line.credit
3941
amount_currency = self.company_id.currency_id
@@ -80,6 +82,16 @@ def _get_reconcile_line(self, line, kind, is_counterpart=False, max_amount=False
8082
"analytic_distribution": line.analytic_distribution,
8183
"kind": kind,
8284
}
85+
if from_unreconcile:
86+
vals.update(
87+
{
88+
"id": False,
89+
"counterpart_line_id": (
90+
line.matched_debit_ids.mapped("debit_move_id")
91+
| line.matched_credit_ids.mapped("credit_move_id")
92+
).id,
93+
}
94+
)
8395
if not float_is_zero(
8496
amount - original_amount, precision_digits=line.currency_id.decimal_places
8597
):

account_reconcile_oca/static/description/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -367,7 +367,7 @@ <h1 class="title">Account Reconcile Oca</h1>
367367
!! This file is generated by oca-gen-addon-readme !!
368368
!! changes will be overwritten. !!
369369
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
370-
!! source digest: sha256:9dd741145a7d3454af97f97eb432cc4bb1718e9b9d0cef6ec314887e2fb25296
370+
!! source digest: sha256:fb0fd744eefd0185149b04302d378a12ae62c7db864b2230c6d71149eda92e79
371371
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
372372
<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>
373373
<p>This addon allows to reconcile bank statements and account marked as <cite>reconcile</cite>.</p>

account_reconcile_oca/static/src/xml/reconcile.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@
6767
</th>
6868
<th class="text-end">Debit</th>
6969
<th class="text-end">Credit</th>
70-
<th />
70+
<th t-if="! props.record.data.is_reconciled" />
7171
</thead>
7272
<tbody>
7373
<t
@@ -130,7 +130,7 @@
130130
class="btn fa fa-trash-o"
131131
role="button"
132132
t-on-click="(ev) => this.onTrashLine(ev, reconcile_line)"
133-
t-if="reconcile_line.kind == 'other'"
133+
t-if="reconcile_line.kind == 'other' &amp;&amp; ! props.record.data.is_reconciled"
134134
/>
135135
</td>
136136
</tr>

account_reconcile_oca/views/account_bank_statement_line.xml

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@
143143
<button
144144
name="unreconcile_bank_line"
145145
type="object"
146-
string="Reset"
146+
string="Unreconcile"
147147
accesskey="r"
148148
class="btn btn-warning"
149149
attrs="{'invisible': [('is_reconciled', '=', False)]}"
@@ -152,7 +152,7 @@
152152
<button
153153
name="clean_reconcile"
154154
type="object"
155-
string="Clean"
155+
string="Reset reconciliation"
156156
class="btn btn-secondary"
157157
attrs="{'invisible': [('is_reconciled', '=', True)]}"
158158
/>
@@ -255,6 +255,7 @@
255255
string="Amount"
256256
attrs="{'readonly': ['|', ('manual_reference', '=', False), ('is_reconciled', '=', True)]}"
257257
/>
258+
<field name="manual_currency_id" invisible="1" />
258259
<field name="manual_original_amount" invisible="1" />
259260
<field name="manual_move_type" invisible="1" />
260261
<label
@@ -287,6 +288,10 @@
287288
</group>
288289
</group>
289290
</page>
291+
<page name="narration" string="Narration">
292+
<field name="payment_ref" />
293+
<field name="narration" />
294+
</page>
290295
<page name="chatter" string="Chatter">
291296
<field name="move_id" widget="account_reconcile_oca_chatter" />
292297
</page>

0 commit comments

Comments
 (0)