forked from tvtma/OpenUpgrade
-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[FIX] hr_fleet: add pre-migration to create value for compute field w…
…ith store=true by sql instead of auto orm
- Loading branch information
1 parent
1b32e71
commit 3065537
Showing
3 changed files
with
37 additions
and
2 deletions.
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
35 changes: 35 additions & 0 deletions
35
openupgrade_scripts/scripts/hr_fleet/16.0.1.0/pre-migration.py
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,35 @@ | ||
from openupgradelib import openupgrade | ||
|
||
|
||
def create_drive_employee(env): | ||
openupgrade.logged_query( | ||
env.cr, | ||
""" | ||
ALTER TABLE fleet_vehicle_assignation_log | ||
ADD IF NOT EXISTS driver_employee_id INT | ||
""", | ||
) | ||
|
||
openupgrade.logged_query( | ||
env.cr, | ||
""" | ||
SELECT id, driver_employee_id | ||
FROM fleet_vehicle | ||
""", | ||
) | ||
|
||
for vehicle in env.cr.fetchall(): | ||
openupgrade.logged_query( | ||
env.cr, | ||
""" | ||
UPDATE fleet_vehicle_assignation_log | ||
SET driver_employee_id = %s | ||
WHERE vehicle_id = %s | ||
""", | ||
(vehicle[1], vehicle[0]), | ||
) | ||
|
||
|
||
@openupgrade.migrate() | ||
def migrate(env, version): | ||
create_drive_employee(env) |
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