Browse Source

[FIX] open invoices - last_rec_date field value cannot be before the period start date

pull/369/head
Jacques-Etienne Baudoux 7 years ago
parent
commit
24d040d917
  1. 8
      account_financial_report_webkit/migrations/8.0.1.2.0/post-migration.py
  2. 12
      account_financial_report_webkit/models/account_move_line.py

8
account_financial_report_webkit/migrations/8.0.1.2.0/post-migration.py

@ -17,13 +17,15 @@ def migrate(cr, version):
"""
UPDATE account_move_line SET last_rec_date = rec_data.aml_date
FROM (
SELECT rec.id, max(aml.date) as aml_date
SELECT rec.id, max(greatest(aml.date,ap.date_start)) as aml_date
FROM account_move_line aml
JOIN account_period ap ON aml.period_id=ap.id
JOIN account_move_reconcile rec
ON rec.id = aml.reconcile_id
GROUP BY rec.id
) as rec_data
WHERE rec_data.id = account_move_line.reconcile_id
AND account_move_line.reconcile_id IS NOT NULL
"""
)
@ -31,12 +33,14 @@ def migrate(cr, version):
"""
UPDATE account_move_line SET last_rec_date = rec_data.aml_date
FROM (
SELECT rec.id, max(aml.date) as aml_date
SELECT rec.id, max(greatest(aml.date,ap.date_start)) as aml_date
FROM account_move_line aml
JOIN account_period ap ON aml.period_id=ap.id
JOIN account_move_reconcile rec
ON rec.id = aml.reconcile_partial_id
GROUP BY rec.id
) as rec_data
WHERE rec_data.id = account_move_line.reconcile_partial_id
AND account_move_line.reconcile_partial_id IS NOT NULL
"""
)

12
account_financial_report_webkit/models/account_move_line.py

@ -30,10 +30,14 @@ class AccountMoveLine(models.Model):
for line in self:
if line.reconcile_id:
move_lines = line.reconcile_id.line_id
last_line = move_lines.sorted(lambda l: l.date)[-1]
line.last_rec_date = last_line.date
last_line = move_lines.sorted(
lambda l: max(l.date, l.period_id.date_start))[-1]
line.last_rec_date = max(
last_line.date, last_line.period_id.date_start)
elif line.reconcile_partial_id:
move_lines = line.reconcile_partial_id.line_partial_ids
last_line = move_lines.sorted(lambda l: l.date)[-1]
line.last_rec_date = last_line.date
last_line = move_lines.sorted(
lambda l: max(l.date, l.period_id.date_start))[-1]
line.last_rec_date = max(
last_line.date, last_line.period_id.date_start)
Loading…
Cancel
Save