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.
[MIG+IMP][14.0] fleet: move data from fleet_vehicle_cost to fleet_veh…
…icle_log_services (#265)
- Loading branch information
1 parent
35bc115
commit 83f5f09
Showing
2 changed files
with
99 additions
and
0 deletions.
There are no files selected for viewing
30 changes: 30 additions & 0 deletions
30
openupgrade_scripts/scripts/fleet/14.0.0.1/end-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,30 @@ | ||
from openupgradelib import openupgrade | ||
|
||
|
||
def _check_viin_fleet_installed(env): | ||
env.cr.execute(""" | ||
SELECT * | ||
FROM ir_module_module | ||
WHERE ir_module_module.state = 'installed'; | ||
""" | ||
) | ||
modules = env.cr.fetchone() | ||
if modules: | ||
return True | ||
return False | ||
|
||
def _move_price_unit_from_fuel_to_service(env): | ||
openupgrade.logged_query( | ||
env.cr,""" | ||
UPDATE fleet_vehicle_log_services s | ||
SET quantity = f.liter, | ||
price_unit = f.price_per_liter | ||
FROM fleet_vehicle_log_fuel f | ||
WHERE s.cost_id = f.cost_id and s.amount <> 0; | ||
""" | ||
) | ||
|
||
@openupgrade.migrate() | ||
def migrate(env, version): | ||
if _check_viin_fleet_installed(env): | ||
_move_price_unit_from_fuel_to_service(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