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.

43 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. string='Last reconciliation date',
  17. help="The date of the last reconciliation (full or partial) "
  18. "account move line."
  19. )
  20. @api.depends(
  21. 'reconcile_id.line_id.date',
  22. 'reconcile_partial_id.line_partial_ids.date')
  23. def _compute_last_rec_date(self):
  24. for line in self:
  25. if line.reconcile_id:
  26. move_lines = line.reconcile_id.line_id
  27. last_line = move_lines.sorted(
  28. lambda l: max(l.date, l.period_id.date_start))[-1]
  29. line.last_rec_date = max(
  30. last_line.date, last_line.period_id.date_start)
  31. elif line.reconcile_partial_id:
  32. move_lines = line.reconcile_partial_id.line_partial_ids
  33. last_line = move_lines.sorted(
  34. lambda l: max(l.date, l.period_id.date_start))[-1]
  35. line.last_rec_date = max(
  36. last_line.date, last_line.period_id.date_start)