Skip to content

Commit

Permalink
[9.0][IMP] purchase_request: add post-migration script.
Browse files Browse the repository at this point in the history
  • Loading branch information
LoisRForgeFlow committed Jun 21, 2017
1 parent a0577a7 commit c223cf1
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 1 deletion.
5 changes: 4 additions & 1 deletion purchase_request/__openerp__.py
Expand Up @@ -6,7 +6,10 @@
"name": "Purchase Request",
"author": "Eficent Business and IT Consulting Services S.L., "
"Odoo Community Association (OCA)",
"version": "9.0.1.0.0",
"version": "9.0.1.0.1",
"summary": "Use this module to have notification of requirements of "
"materials and/or external services and keep track of such "
"requirements.",
"category": "Purchase Management",
"depends": [
"purchase",
Expand Down
22 changes: 22 additions & 0 deletions purchase_request/migrations/9.0.1.0.1/post-migration.py
@@ -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)

0 comments on commit c223cf1

Please sign in to comment.