Skip to content

Commit

Permalink
[ADD] bank reconciliation comp. with reconcile_on_company_currency
Browse files Browse the repository at this point in the history
  • Loading branch information
jjscarafia committed Sep 12, 2023
1 parent a5ae6a4 commit 8dd0e03
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 2 deletions.
1 change: 1 addition & 0 deletions account_accountant_ux/README.rst
Expand Up @@ -18,6 +18,7 @@ Accounting Reports UX
#. This module add to set the company in the wizard to set the account lock date.
#. Add an option to force company currency on follow ups
#. Mejorar que para asientos migrados desde 13 que están vinculados a un pago y linea de extracto a la vez, el botón "pagos" te lleve efectivamente al pago (odoo te lleva a la linea de extracto pero ya existe un botón para esto)
#. Ajustar conciliacion bancaria para compatibilidad con la opción "reconcile_on_company_currency"

Installation
============
Expand Down
38 changes: 36 additions & 2 deletions account_accountant_ux/models/bank_rec_widget.py
@@ -1,5 +1,7 @@
from odoo import models, api
from odoo.tools.misc import formatLang
from odoo import models, api, Command
# from odoo.tools.misc import formatLang
from odoo.exceptions import UserError


class BankRecWidget(models.Model):
_inherit = "bank.rec.widget"
Expand Down Expand Up @@ -29,3 +31,35 @@ def collect_global_info_data(self, journal_id):
# }

return {'balance_amount': None}

def _lines_widget_recompute_exchange_diff(self):
self.ensure_one()
self._ensure_loaded_lines()

line_ids_commands = []

# Clean the existing lines.
for exchange_diff in self.line_ids.filtered(lambda x: x.flag == 'exchange_diff'):
line_ids_commands.append(Command.unlink(exchange_diff.id))

new_amls = self.line_ids.filtered(lambda x: x.flag == 'new_aml')
if self.company_id.reconcile_on_company_currency:

accounts_currency_ids = []
for new_aml in new_amls:
if new_aml.account_id.currency_id not in accounts_currency_ids:
accounts_currency_ids.append(new_aml.account_id.currency_id)
if len(accounts_currency_ids) > 1:
raise UserError(
'No puede conciliar en el mismo registro apuntes de cuentas con moneda secundaria y apuntes sin '
'cuando tiene configurada la compañía con "Reconcile On Company Currency"')
if not accounts_currency_ids or not accounts_currency_ids[0]:
line_ids_commands = []

# Clean the existing lines.
for exchange_diff in self.line_ids.filtered(lambda x: x.flag == 'exchange_diff'):
line_ids_commands.append(Command.unlink(exchange_diff.id))

self.line_ids = line_ids_commands
return
super()._lines_widget_recompute_exchange_diff()

0 comments on commit 8dd0e03

Please sign in to comment.