Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FIX]commented function to generate multi-currency payment reconciliation #351

Open
wants to merge 6 commits into
base: 13.0
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions account_financial_amount/models/account_move_line.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ class AccountMoveLine(models.Model):
@api.depends('debit', 'credit')
def _compute_financial_amounts(self):
date = fields.Date.today()
if self._context.get('date_account', False):
date = self._context.get('date_account')
for line in self:
financial_amount = (
line.currency_id and line.currency_id._convert(
Expand Down
40 changes: 20 additions & 20 deletions account_ux/models/account_move_line.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,23 +41,23 @@ def action_open_related_document(self):
'res_id': res_id,
}

def _reconcile_lines(self, debit_moves, credit_moves, field):
""" Modificamos contexto para que odoo solo concilie el metodo
auto_reconcile_lines teniendo en cuenta la moneda de cia si la cuenta
no tiene moneda.
Va de la mano de la modificación de "create" en
account.partial.reconcile
Para que este cambio funcione bien es ademas importante este parche en odoo
https://github.com/odoo/odoo/pull/63390
"""
if self and self[0].company_id.country_id == self.env.ref('base.ar') and not self[0].account_id.currency_id:
field = 'amount_residual'
return super()._reconcile_lines(debit_moves, credit_moves, field)

def reconcile(self, writeoff_acc_id=False, writeoff_journal_id=False):
""" This is needed if you reconcile, for eg, 1 USD to 1 USD but in an ARS account, by default
odoo make a full reconcile and exchange
"""
if self and self[0].company_id.country_id == self.env.ref('base.ar') and not self[0].account_id.currency_id:
self = self.with_context(no_exchange_difference=True)
return super().reconcile(writeoff_acc_id=writeoff_acc_id, writeoff_journal_id=writeoff_journal_id)
# def _reconcile_lines(self, debit_moves, credit_moves, field):
# """ Modificamos contexto para que odoo solo concilie el metodo
# auto_reconcile_lines teniendo en cuenta la moneda de cia si la cuenta
# no tiene moneda.
# Va de la mano de la modificación de "create" en
# account.partial.reconcile
# Para que este cambio funcione bien es ademas importante este parche en odoo
# https://github.com/odoo/odoo/pull/63390
# """
# if self and self[0].company_id.country_id == self.env.ref('base.ar') and not self[0].account_id.currency_id:
# field = 'amount_residual'
# return super()._reconcile_lines(debit_moves, credit_moves, field)

# def reconcile(self, writeoff_acc_id=False, writeoff_journal_id=False):
# """ This is needed if you reconcile, for eg, 1 USD to 1 USD but in an ARS account, by default
# odoo make a full reconcile and exchange
# """
# if self and self[0].company_id.country_id == self.env.ref('base.ar') and not self[0].account_id.currency_id:
# self = self.with_context(no_exchange_difference=True)
# return super().reconcile(writeoff_acc_id=writeoff_acc_id, writeoff_journal_id=writeoff_journal_id)
25 changes: 13 additions & 12 deletions account_ux/models/account_partial_reconcile.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,16 @@
class AccountPartialReconcile(models.Model):
_inherit = "account.partial.reconcile"

@api.model
def create(self, vals):
""" ademas de mandar en el contexto en el metodo reconcile, hacemos
que el partial reconcile que crea el metodo auto_reconcile_lines
no tenga moneda en la misma situación (podriamos ).
Va de la mano de la modificacion de "def reconcile" en aml
"""
if vals.get('currency_id'):
account = self.env['account.move.line'].browse(vals.get('debit_move_id')).account_id
if account.company_id.country_id == self.env.ref('base.ar') and not account.currency_id:
vals.update({'currency_id': False, 'amount_currency': 0.0})
return super().create(vals)
#TODO revisar la compatibilidad de esta funcion con el diferencial de cambio
# @API.MODEL
# DEF CREATE(SELF, VALS):
# """ ADEMAS DE MANDAR EN EL CONTEXTO EN EL METODO RECONCILE, HACEMOS
# QUE EL PARTIAL RECONCILE QUE CREA EL METODO AUTO_RECONCILE_LINES
# NO TENGA MONEDA EN LA MISMA SITUACIÓN (PODRIAMOS ).
# VA DE LA MANO DE LA MODIFICACION DE "DEF RECONCILE" EN AML
# """
# IF VALS.GET('CURRENCY_ID'):
# ACCOUNT = SELF.ENV['ACCOUNT.MOVE.LINE'].BROWSE(VALS.GET('DEBIT_MOVE_ID')).ACCOUNT_ID
# IF ACCOUNT.COMPANY_ID.COUNTRY_ID == SELF.ENV.REF('BASE.AR') AND NOT ACCOUNT.CURRENCY_ID:
# VALS.UPDATE({'CURRENCY_ID': FALSE, 'AMOUNT_CURRENCY': 0.0})
# RETURN SUPER().CREATE(VALS)