Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[9.0][IMP] purchase_request: add post-migration script.
- Loading branch information
1 parent
a0577a7
commit c223cf1
Showing
2 changed files
with
26 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
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,22 @@ | ||
# -*- coding: utf-8 -*- | ||
# Copyright 2017 Eficent Business and IT Consulting Services S.L. | ||
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl-3.0). | ||
|
||
import logging | ||
logger = logging.getLogger(__name__) | ||
|
||
|
||
def update_rejected_requests(cr): | ||
logger.info('Updating purchase request lines that need to be cancelled.') | ||
cr.execute(""" | ||
UPDATE purchase_request_line prl | ||
SET cancelled = true | ||
FROM purchase_request pr | ||
WHERE pr.state = 'rejected' AND prl.request_id = pr.id | ||
""") | ||
|
||
|
||
def migrate(cr, version): | ||
if not version: | ||
return | ||
update_rejected_requests(cr) |