mirror of
https://github.com/odoo/runbot.git
synced 2025-03-15 15:35:46 +07:00
Change fallback_id to many2many
A Community addon can depend on more than just an odoo server, but other addon repos Bump version Add migration script Signed-off-by: Sandy Carter <sandy.carter@savoirfairelinux.com>
This commit is contained in:
parent
0fb5ef92c4
commit
9dbc76d9ab
@ -2,7 +2,7 @@
|
||||
'name': 'Runbot',
|
||||
'category': 'Website',
|
||||
'summary': 'Runbot',
|
||||
'version': '1.0',
|
||||
'version': '1.1',
|
||||
'description': "Runbot",
|
||||
'author': 'OpenERP SA',
|
||||
'depends': ['website'],
|
||||
|
33
runbot/migrations/8.0.1.1/post-migration.py
Normal file
33
runbot/migrations/8.0.1.1/post-migration.py
Normal file
@ -0,0 +1,33 @@
|
||||
# -*- encoding: utf-8 -*-
|
||||
|
||||
|
||||
from openerp import SUPERUSER_ID
|
||||
from openerp.modules.registry import RegistryManager
|
||||
|
||||
|
||||
def get_legacy_name(original_name, version):
|
||||
return 'legacy_%s_%s' % (version.replace('.', '_'), original_name)
|
||||
|
||||
|
||||
def m2o_to_x2m(cr, model, table, field, source_field):
|
||||
cr.execute('SELECT id, %(field)s '
|
||||
'FROM %(table)s '
|
||||
'WHERE %(field)s is not null' % {
|
||||
'table': table,
|
||||
'field': source_field,
|
||||
})
|
||||
for row in cr.fetchall():
|
||||
model.write(cr, SUPERUSER_ID, row[0], {field: [(4, row[1])]})
|
||||
|
||||
|
||||
def migrate(cr, version):
|
||||
if not version:
|
||||
return
|
||||
registry = RegistryManager.get(cr.dbname)
|
||||
m2o_to_x2m(
|
||||
cr,
|
||||
registry['runbot.repo'],
|
||||
'runbot_repo',
|
||||
'dependency_ids',
|
||||
get_legacy_name('fallback_id', version),
|
||||
)
|
35
runbot/migrations/8.0.1.1/pre-migration.py
Normal file
35
runbot/migrations/8.0.1.1/pre-migration.py
Normal file
@ -0,0 +1,35 @@
|
||||
# -*- encoding: utf-8 -*-
|
||||
|
||||
from openerp import release
|
||||
import logging
|
||||
|
||||
logger = logging.getLogger('upgrade')
|
||||
|
||||
|
||||
def get_legacy_name(original_name, version):
|
||||
return 'legacy_%s_%s' % (version.replace('.', '_'), original_name)
|
||||
|
||||
|
||||
def rename_columns(cr, column_spec, version):
|
||||
for table, renames in column_spec.iteritems():
|
||||
for old, new in renames:
|
||||
if new is None:
|
||||
new = get_legacy_name(old, version)
|
||||
logger.info("table %s, column %s: renaming to %s",
|
||||
table, old, new)
|
||||
cr.execute('ALTER TABLE "%s" RENAME "%s" TO "%s"'
|
||||
% (table, old, new,))
|
||||
cr.execute('DROP INDEX IF EXISTS "%s_%s_index"'
|
||||
% (table, old))
|
||||
|
||||
column_renames = {
|
||||
'runbot_repo': [
|
||||
('fallback_id', None)
|
||||
]
|
||||
}
|
||||
|
||||
|
||||
def migrate(cr, version):
|
||||
if not version:
|
||||
return
|
||||
rename_columns(cr, column_renames, version)
|
@ -172,8 +172,12 @@ class runbot_repo(osv.osv):
|
||||
'nginx': fields.boolean('Nginx'),
|
||||
'auto': fields.boolean('Auto'),
|
||||
'duplicate_id': fields.many2one('runbot.repo', 'Repository for finding duplicate builds'),
|
||||
'fallback_id': fields.many2one('runbot.repo', 'Fallback repo'),
|
||||
'modules': fields.char("Modules to Install", help="Comma-separated list of modules to install and test."),
|
||||
'dependency_ids': fields.many2many(
|
||||
'runbot.repo', 'runbot_repo_dep_rel',
|
||||
id1='dependant_id', id2='dependency_id',
|
||||
string='Extra dependencies',
|
||||
help="Community addon repos which need to be present to run tests."),
|
||||
'token': fields.char("Github token"),
|
||||
}
|
||||
_defaults = {
|
||||
@ -544,16 +548,17 @@ class runbot_build(osv.osv):
|
||||
if os.path.isdir(build.path('bin/addons')):
|
||||
shutil.move(build.path('bin'), build.server())
|
||||
|
||||
# fallback for addons-only community/projet branches
|
||||
# fallback for addons-only community/project branches
|
||||
if not os.path.isfile(build.server('__init__.py')):
|
||||
# Find modules to test and store in build
|
||||
modules_to_test = glob.glob(build.path('*/__openerp__.py'))
|
||||
build.write({'modules': ','.join(modules_to_test)})
|
||||
for i in modules_to_test:
|
||||
shutil.move(os.path.dirname(i), build.server('addons'))
|
||||
name = build.branch_id.branch_name.split('-',1)[0]
|
||||
if build.repo_id.fallback_id:
|
||||
build.repo_id.fallback_id.git_export(name, build.path())
|
||||
for extra_repo in build.repo_id.dependency_ids:
|
||||
extra_repo.git_export(name, build.path())
|
||||
# Finally move all addons to openerp/addons
|
||||
for module in glob.glob(build.path('*/__openerp__.py')):
|
||||
shutil.move(os.path.dirname(module), build.path('openerp/addons'))
|
||||
|
||||
# move all addons to server addons path
|
||||
for i in glob.glob(build.path('addons/*')):
|
||||
|
@ -23,8 +23,10 @@
|
||||
<field name="auto"/>
|
||||
<field name="jobs"/>
|
||||
<field name="nginx"/>
|
||||
<field name="fallback_id"/>
|
||||
<field name="duplicate_id"/>
|
||||
<field name="dependency_ids">
|
||||
<tree><field name="name"/></tree>
|
||||
</field>
|
||||
<field name="modules"/>
|
||||
<field name="token"/>
|
||||
</group>
|
||||
|
Loading…
Reference in New Issue
Block a user