-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[FIX] joint_buying_base: Recompute all the start_date of the model jo…
…int_buying_transport_request, as the previous value was bad computed
- Loading branch information
1 parent
0b630f9
commit 0c8470e
Showing
2 changed files
with
38 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
# Copyright (C) 2024-Today: GRAP (http://www.grap.coop) | ||
# @author: Sylvain LE GAL (https://twitter.com/legalsylvain) | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). | ||
|
||
import logging | ||
|
||
from openupgradelib import openupgrade | ||
|
||
_logger = logging.getLogger(__name__) | ||
|
||
|
||
@openupgrade.migrate() | ||
def migrate(env, version): | ||
|
||
_logger.info( | ||
"Fix bad computation of joint_buying_transport_request.start_date field." | ||
) | ||
openupgrade.logged_query( | ||
""" | ||
UPDATE joint_buying_transport_request tr_main | ||
SET start_date = tmp.min_start_date | ||
FROM ( | ||
SELECT tr.id as transport_request_id, | ||
min(tl.start_date) as min_start_date | ||
FROM joint_buying_transport_request tr | ||
INNER JOIN joint_buying_transport_request_line trl | ||
ON trl.request_id = tr.id | ||
INNER JOIN joint_buying_tour_line tl | ||
ON tl.id = trl.tour_line_id | ||
WHERE tr.state = 'computed' | ||
GROUP BY tr.id | ||
) as tmp | ||
WHERE | ||
tr_main.id = tmp.transport_request_id | ||
AND tr_main.start_date != tmp.min_start_date; | ||
""" | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters