changeset 3:e1d3f7a0a7d9

Update to 4.4 - rename ir.module.module into ir.module - rename installed into activated
author Cédric Krier <ced@b2ck.com>
date Wed, 21 Jun 2017 16:31:58 +0200
parents b009a7515720
children 17d65cd9f9e7
files migration.py
diffstat 1 files changed, 38 insertions(+), 38 deletions(-) [+]
line wrap: on
line diff
--- a/migration.py	Sun Jun 11 21:43:42 2017 +0200
+++ b/migration.py	Wed Jun 21 16:31:58 2017 +0200
@@ -18,49 +18,49 @@
 
 def main(oe_database, tryton_database, modules, password, languages, load):
     config.set_trytond(tryton_database, password)
-    to_install, installed = install_modules(modules)
+    to_activate, activated = activate_modules(modules)
 
     conn = psycopg2.connect(oe_database)
     cur = conn.cursor(cursor_factory=psycopg2.extras.NamedTupleCursor)
 
-    if 'account_invoice' in installed:
-        migrate_payment_term(installed, cur)
+    if 'account_invoice' in activated:
+        migrate_payment_term(activated, cur)
 
-    if 'party' in installed:
-        migrate_party(installed, cur)
+    if 'party' in activated:
+        migrate_party(activated, cur)
 
-    if 'company' in installed:
-        migrate_company(installed, cur)
+    if 'company' in activated:
+        migrate_company(activated, cur)
 
-    if 'account_fr' in installed:
+    if 'account_fr' in activated:
         create_chart_of_account('Plan comptable (French)', '4111', '4011')
 
-    if load.get('account') and 'account' in installed:
+    if load.get('account') and 'account' in activated:
         load_csv(Model.get('account.account'), load['account'])
 
-    if 'company' in installed:
-        migrate_employee(installed, cur)
+    if 'company' in activated:
+        migrate_employee(activated, cur)
 
-    if 'product' in installed:
+    if 'product' in activated:
         if load.get('uom'):
             load_csv(Model.get('product.uom'), load['uom'])
-        migrate_product(installed, cur)
+        migrate_product(activated, cur)
 
-    if 'sale' in installed:
-        migrate_sale(installed, cur)
+    if 'sale' in activated:
+        migrate_sale(activated, cur)
 
-    if 'sale_opportunity' in installed:
-        migrate_opportunity(installed, cur)
+    if 'sale_opportunity' in activated:
+        migrate_opportunity(activated, cur)
 
-    if 'purchase' in installed:
-        migrate_purchase(installed, cur)
+    if 'purchase' in activated:
+        migrate_purchase(activated, cur)
 
-    if 'account_invoice' in installed:
-        migrate_invoice(installed, cur)
+    if 'account_invoice' in activated:
+        migrate_invoice(activated, cur)
 
-    if 'account' in installed:
-        migrate_fiscalyear(installed, cur)
-        migrate_account_balance(installed, cur)
+    if 'account' in activated:
+        migrate_fiscalyear(activated, cur)
+        migrate_account_balance(activated, cur)
 
     cur.close()
     conn.close()
@@ -85,30 +85,30 @@
             Model.import_data(header, [data], Model._config.context)
 
 
-def install_modules(modules):
-    Module = Model.get('ir.module.module')
+def activate_modules(modules):
+    Module = Model.get('ir.module')
     modules = Module.find([
             ('name', 'in', modules),
-            ('state', '!=', 'installed'),
+            ('state', '!=', 'activated'),
             ])
-    [m.click('install') for m in modules]
-    modules = [m.name for m in Module.find([('state', '=', 'to install')])]
-    Wizard('ir.module.module.install_upgrade').execute('upgrade')
+    [m.click('activate') for m in modules]
+    modules = [m.name for m in Module.find([('state', '=', 'to activate')])]
+    Wizard('ir.module.activate_upgrade').execute('upgrade')
 
-    ConfigWizardItem = Model.get('ir.module.module.config_wizard.item')
+    ConfigWizardItem = Model.get('ir.module.config_wizard.item')
     items = ConfigWizardItem.find([('state', '!=', 'done')])
     for item in items:
         item.state = 'done'
     ConfigWizardItem.save(items)
 
-    installed_modules = [m.name
-        for m in Module.find([('state', '=', 'installed')])]
-    return modules, installed_modules
+    activated_modules = [m.name
+        for m in Module.find([('state', '=', 'activated')])]
+    return modules, activated_modules
 
 
 def setup_languages(languages):
     Lang = Model.get('ir.lang')
-    Module = Model.get('ir.module.module')
+    Module = Model.get('ir.module')
 
     languages = Lang.find([
             ('code', 'in', languages),
@@ -117,8 +117,8 @@
         lang.translatable = True
     Lang.save(languages)
 
-    Module.click(Module.find([('state', '=', 'installed')]), 'upgrade')
-    Wizard('ir.module.module.install_upgrade').execute('upgrade')
+    Module.click(Module.find([('state', '=', 'activated')]), 'upgrade')
+    Wizard('ir.module.activate_upgrade').execute('upgrade')
 
 code2party = {}
 
@@ -1076,7 +1076,7 @@
     parser.add_argument('-m', '--module', dest='modules', nargs='+',
         default=[], metavar='MODULE', help='module to migrate')
     parser.add_argument('-l', '--language', dest='languages', nargs='+',
-        default=[], metavar='LANGUAGE', help='language to install')
+        default=[], metavar='LANGUAGE', help='language to activate')
     parser.add_argument('-oe', dest='oe_database', required=True)
     parser.add_argument('-d', '--database', dest='tryton_database',
         required=True)