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.

42 lines
1.1 KiB

  1. # -*- coding: utf-8 -*-
  2. # © 2016 Savoir-faire Linux
  3. # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
  4. import logging
  5. _logger = logging.getLogger(__name__)
  6. def migrate(cr, version):
  7. if not version:
  8. return
  9. _logger.info('Updating column last_rec_date on account_move_line')
  10. cr.execute(
  11. """
  12. UPDATE account_move_line SET last_rec_date = rec_data.aml_date
  13. FROM (
  14. SELECT rec.id, max(aml.date) as aml_date
  15. FROM account_move_line aml
  16. JOIN account_move_reconcile rec
  17. ON rec.id = aml.reconcile_id
  18. GROUP BY rec.id
  19. ) as rec_data
  20. WHERE rec_data.id = account_move_line.reconcile_id
  21. """
  22. )
  23. cr.execute(
  24. """
  25. UPDATE account_move_line SET last_rec_date = rec_data.aml_date
  26. FROM (
  27. SELECT rec.id, max(aml.date) as aml_date
  28. FROM account_move_line aml
  29. JOIN account_move_reconcile rec
  30. ON rec.id = aml.reconcile_partial_id
  31. GROUP BY rec.id
  32. ) as rec_data
  33. WHERE rec_data.id = account_move_line.reconcile_partial_id
  34. """
  35. )