|
@ -1,6 +1,7 @@ |
|
|
# -*- coding: utf-8 -*- |
|
|
# -*- coding: utf-8 -*- |
|
|
# © 2016 Julien Coux (Camptocamp) |
|
|
# © 2016 Julien Coux (Camptocamp) |
|
|
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). |
|
|
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). |
|
|
|
|
|
from datetime import timedelta |
|
|
|
|
|
|
|
|
from odoo import models, fields, api, _ |
|
|
from odoo import models, fields, api, _ |
|
|
|
|
|
|
|
@ -414,10 +415,6 @@ FROM |
|
|
LEFT JOIN |
|
|
LEFT JOIN |
|
|
account_partial_reconcile pr |
|
|
account_partial_reconcile pr |
|
|
ON ml.balance < 0 AND pr.credit_move_id = ml.id |
|
|
ON ml.balance < 0 AND pr.credit_move_id = ml.id |
|
|
LEFT JOIN |
|
|
|
|
|
account_move_line ml_future |
|
|
|
|
|
ON ml.balance < 0 AND pr.debit_move_id = ml_future.id |
|
|
|
|
|
AND ml_future.date > %s |
|
|
|
|
|
LEFT JOIN |
|
|
LEFT JOIN |
|
|
account_move_line ml_past |
|
|
account_move_line ml_past |
|
|
ON ml.balance < 0 AND pr.debit_move_id = ml_past.id |
|
|
ON ml.balance < 0 AND pr.debit_move_id = ml_past.id |
|
@ -428,27 +425,20 @@ FROM |
|
|
LEFT JOIN |
|
|
LEFT JOIN |
|
|
account_partial_reconcile pr |
|
|
account_partial_reconcile pr |
|
|
ON ml.balance > 0 AND pr.debit_move_id = ml.id |
|
|
ON ml.balance > 0 AND pr.debit_move_id = ml.id |
|
|
LEFT JOIN |
|
|
|
|
|
account_move_line ml_future |
|
|
|
|
|
ON ml.balance > 0 AND pr.credit_move_id = ml_future.id |
|
|
|
|
|
AND ml_future.date > %s |
|
|
|
|
|
LEFT JOIN |
|
|
LEFT JOIN |
|
|
account_move_line ml_past |
|
|
account_move_line ml_past |
|
|
ON ml.balance > 0 AND pr.credit_move_id = ml_past.id |
|
|
ON ml.balance > 0 AND pr.credit_move_id = ml_past.id |
|
|
AND ml_past.date <= %s |
|
|
AND ml_past.date <= %s |
|
|
""" |
|
|
""" |
|
|
sub_query += """ |
|
|
sub_query += """ |
|
|
|
|
|
LEFT JOIN account_full_reconcile afr ON afr.id = ml.full_reconcile_id |
|
|
WHERE |
|
|
WHERE |
|
|
ra.report_id = %s |
|
|
ra.report_id = %s |
|
|
|
|
|
AND ml.full_reconcile_id IS NULL OR afr.create_date >= %s |
|
|
GROUP BY |
|
|
GROUP BY |
|
|
ml.id, |
|
|
ml.id, |
|
|
ml.balance, |
|
|
ml.balance, |
|
|
ml.amount_currency |
|
|
ml.amount_currency |
|
|
HAVING |
|
|
|
|
|
( |
|
|
|
|
|
ml.full_reconcile_id IS NULL |
|
|
|
|
|
OR MAX(ml_future.id) IS NOT NULL |
|
|
|
|
|
) |
|
|
|
|
|
""" |
|
|
""" |
|
|
return sub_query |
|
|
return sub_query |
|
|
|
|
|
|
|
@ -617,17 +607,20 @@ ORDER BY |
|
|
ORDER BY |
|
|
ORDER BY |
|
|
a.code, ml.date, ml.id |
|
|
a.code, ml.date, ml.id |
|
|
""" |
|
|
""" |
|
|
|
|
|
full_reconcile_date = fields.Datetime.to_string( |
|
|
|
|
|
fields.Datetime.from_string(self.date_at) + timedelta(days=1)) |
|
|
self.env.cr.execute( |
|
|
self.env.cr.execute( |
|
|
query_inject_move_line, |
|
|
query_inject_move_line, |
|
|
(self.date_at, |
|
|
(self.date_at, |
|
|
self.date_at, |
|
|
|
|
|
self.id, |
|
|
self.id, |
|
|
self.date_at, |
|
|
|
|
|
|
|
|
full_reconcile_date, |
|
|
self.date_at, |
|
|
self.date_at, |
|
|
self.id, |
|
|
self.id, |
|
|
|
|
|
full_reconcile_date, |
|
|
self.env.uid, |
|
|
self.env.uid, |
|
|
self.id, |
|
|
self.id, |
|
|
self.date_at,) |
|
|
|
|
|
|
|
|
self.date_at, |
|
|
|
|
|
) |
|
|
) |
|
|
) |
|
|
|
|
|
|
|
|
def _compute_partners_and_accounts_cumul(self): |
|
|
def _compute_partners_and_accounts_cumul(self): |
|
|