Files
odoo_source/addons/account/models/account_full_reconcile.py
T
wan b13f40c83e [FIX] account: use context_today instead of today
The problem of using fields.Date.today() instead of
fields.Date.context_today() arose with the recent changes in the
account.move._post() method used in the POS tests, around 1 am.

This commit changes all occurences of today to context_today.

closes odoo/odoo#55511

Signed-off-by: Laurent Smet <smetl@users.noreply.github.com>
2020-08-06 10:07:28 +00:00

38 lines
1.6 KiB
Python

# -*- coding: utf-8 -*-
from odoo import api, fields, models, _
class AccountFullReconcile(models.Model):
_name = "account.full.reconcile"
_description = "Full Reconcile"
name = fields.Char(string='Number', required=True, copy=False, default=lambda self: self.env['ir.sequence'].next_by_code('account.reconcile'))
partial_reconcile_ids = fields.One2many('account.partial.reconcile', 'full_reconcile_id', string='Reconciliation Parts')
reconciled_line_ids = fields.One2many('account.move.line', 'full_reconcile_id', string='Matched Journal Items')
exchange_move_id = fields.Many2one('account.move')
def unlink(self):
""" When removing a full reconciliation, we need to revert the eventual journal entries we created to book the
fluctuation of the foreign currency's exchange rate.
We need also to reconcile together the origin currency difference line and its reversal in order to completely
cancel the currency difference entry on the partner account (otherwise it will still appear on the aged balance
for example).
"""
# Avoid cyclic unlink calls when removing partials.
if not self:
return True
moves_to_reverse = self.exchange_move_id
res = super().unlink()
# Reverse all exchange moves at once.
today = fields.Date.context_today(self)
default_values_list = [{
'date': today,
'ref': _('Reversal of: %s') % move.name,
} for move in moves_to_reverse]
moves_to_reverse._reverse_moves(default_values_list, cancel=True)
return res