-
-
Notifications
You must be signed in to change notification settings - Fork 821
Add migration for analytic #802
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| # -*- coding: utf-8 -*- | ||
| # © 2017 Therp BV | ||
| # License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). | ||
| from openupgradelib import openupgrade | ||
|
|
||
| def deactivate_closed_accounts(cr): | ||
| # not using sql to restore account_type but map values | ||
| openupgrade.map_values( | ||
| cr, openupgrade.get_legacy_name('account_type'), | ||
| 'active', [('closed' , False) , ('normal', True)], | ||
| table='account_analytic_account', | ||
| write='sql' | ||
| ) | ||
|
|
||
| @openupgrade.migrate(use_env=True) | ||
| def migrate(env, version): | ||
| cr = env.cr | ||
| deactivate_closed_accounts(cr) |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| # -*- coding: utf-8 -*- | ||
| # © 2017 Therp BV | ||
| # License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). | ||
| from openupgradelib import openupgrade | ||
|
|
||
| @openupgrade.migrate(use_env=True) | ||
| def migrate(env, version): | ||
| cr = env.cr | ||
| # copy columns good practice in pre-mig script format of colum_spec should | ||
| # be: { Table_name_in_db : [( old_column_name , new_column_name, type)] | ||
| # defaults of new columname are fetchable via method get_legacy_name | ||
| openupgrade.copy_columns(cr, { | ||
| 'account_analytic_account' : [ | ||
| ('account_type', None, None), | ||
| ], | ||
| }) |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| - | ||
| this file contains data for automated testing the migration on travis | ||
| - | ||
|
|
||
| - | ||
| create some account_analytic_account that have type == 'closed', in casde the db does not have them in order to verify that the script works and that it will transform those in v10.0 bool ean field active = False | ||
| - | ||
| !record {model: account.analytic.account, id: analytic.ou_analytic_account_c1}: | ||
| name: 'OU Test closed' | ||
| type: 'closed' | ||
| - | ||
| !record {model: account.analytic.account, id: analytic.ou_analytic_account_n1}: | ||
| name: 'OU Test normal 2' | ||
| type: 'normal' | ||
| - | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| # coding: utf-8 | ||
| from openerp.tests.common import TransactionCase | ||
|
|
||
|
|
||
| class TestAnalytic(TransactionCase) | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I have just discovered that this is not being executed, or this would be marked as error, as it misses the final
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm fixing the issues directly for getting a green build: https://travis-ci.org/OCA/OpenUpgrade/builds/232892182#L357
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Partially fixed on 993e0ec. Switching to PR for trying to fix the other error: https://travis-ci.org/OCA/OpenUpgrade/builds/232906089#L428 |
||
|
|
||
| def test_analytic(self): | ||
| self.assertTrue( | ||
| self.env.ref('analytic.ou_analytic_account_c1').active == False | ||
| ) | ||
| self.assertTrue( | ||
| self.env.ref('analytic.ou_analytic_account_n1').active == True | ||
| ) | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't see the test that checks that these accounts are inactive.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ba927fe#diff-21238dc2fbb1a7124cb1ad70747c974eR5