You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

44 lines
1.5 KiB

  1. # -*- coding: utf-8 -*-
  2. # © 2011 Camptocamp SA
  3. # © 2016 Savoir-faire Linux
  4. # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
  5. from openerp import api, fields, models
  6. class AccountMoveLine(models.Model):
  7. """
  8. Overriding Account move line in order to add last_rec_date.
  9. Last rec date is the date of the last reconciliation (full or partial)
  10. account move line
  11. """
  12. _inherit = 'account.move.line'
  13. last_rec_date = fields.Date(
  14. compute='_compute_last_rec_date',
  15. store=True,
  16. index=True,
  17. string='Last reconciliation date',
  18. help="The date of the last reconciliation (full or partial) "
  19. "account move line."
  20. )
  21. @api.depends(
  22. 'reconcile_id.line_id.date',
  23. 'reconcile_partial_id.line_partial_ids.date')
  24. def _compute_last_rec_date(self):
  25. for line in self:
  26. if line.reconcile_id:
  27. move_lines = line.reconcile_id.line_id
  28. last_line = move_lines.sorted(
  29. lambda l: max(l.date, l.period_id.date_start))[-1]
  30. line.last_rec_date = max(
  31. last_line.date, last_line.period_id.date_start)
  32. elif line.reconcile_partial_id:
  33. move_lines = line.reconcile_partial_id.line_partial_ids
  34. last_line = move_lines.sorted(
  35. lambda l: max(l.date, l.period_id.date_start))[-1]
  36. line.last_rec_date = max(
  37. last_line.date, last_line.period_id.date_start)