credativ team mailing list archive
-
credativ team
-
Mailing list archive
-
Message #04902
[Merge] lp:~therp-nl/openupgrade-server/6.1-fix_transactions into lp:openupgrade-server
Holger Brunn (Therp) has proposed merging lp:~therp-nl/openupgrade-server/6.1-fix_transactions into lp:openupgrade-server with lp:~therp-nl/openupgrade-server/6.1-force_deps as a prerequisite.
Requested reviews:
OpenUpgrade Committers (openupgrade-committers)
For more details, see:
https://code.launchpad.net/~therp-nl/openupgrade-server/6.1-fix_transactions/+merge/114357
--
https://code.launchpad.net/~therp-nl/openupgrade-server/6.1-fix_transactions/+merge/114357
Your team OpenUpgrade Committers is requested to review the proposed merge of lp:~therp-nl/openupgrade-server/6.1-fix_transactions into lp:openupgrade-server.
=== modified file 'openerp/addons/base/migrations/6.1.1.3/post-migration.py'
--- openerp/addons/base/migrations/6.1.1.3/post-migration.py 2012-06-11 09:40:30 +0000
+++ openerp/addons/base/migrations/6.1.1.3/post-migration.py 2012-07-11 08:42:21 +0000
@@ -8,6 +8,8 @@
logger = logging.getLogger('OpenUpgrade')
me = os.path.realpath( __file__ )
+obsolete_modules = [ 'smtpclient' ]
+
force_defaults = {
# False results in column value NULL
# None value triggers a call to the model's default function
@@ -16,20 +18,35 @@
]
}
+def mark_obsolete_modules(cr):
+ """
+ Remove modules that are known to be obsolete
+ in this version of the OpenERP server.
+ """
+ openupgrade.logged_query(
+ cr, """
+ UPDATE
+ ir_module_module
+ SET
+ state='to remove'
+ WHERE
+ state='installed'
+ AND name in %s
+ """,
+ (tuple(obsolete_modules),))
+
+@openupgrade.migrate()
def migrate(cr, version):
- try:
- logger.info("%s called", me)
- pool = pooler.get_pool(cr.dbname)
- openupgrade.set_defaults(cr, pool, force_defaults, force=True)
- openupgrade.load_data(cr, 'base', 'migrations/6.1.1.3/data/base_data.xml')
- openupgrade.load_data(cr, 'base', 'migrations/6.1.1.3/data/base_security.xml')
- openupgrade.load_data(cr, 'base', 'migrations/6.1.1.3/data/ir.model.access.csv')
- #force recreating module categories for all categories without xmlid
- #this fixes addons getting wrong category_ids assigned in case of
- #multiple categories with the same name
- cr.execute("""
- delete from ir_module_category where id not in
- (select res_id from ir_model_data where model='ir.module.category')
- """)
- except Exception, e:
- raise osv.except_osv("OpenUpgrade", '%s: %s' % (me, e))
+ pool = pooler.get_pool(cr.dbname)
+ openupgrade.set_defaults(cr, pool, force_defaults, force=True)
+ openupgrade.load_data(cr, 'base', 'migrations/6.1.1.3/data/base_data.xml')
+ openupgrade.load_data(cr, 'base', 'migrations/6.1.1.3/data/base_security.xml')
+ openupgrade.load_data(cr, 'base', 'migrations/6.1.1.3/data/ir.model.access.csv')
+ #force recreating module categories for all categories without xmlid
+ #this fixes addons getting wrong category_ids assigned in case of
+ #multiple categories with the same name
+ cr.execute("""
+ delete from ir_module_category where id not in
+ (select res_id from ir_model_data where model='ir.module.category')
+ """)
+ mark_obsolete_modules(cr)
=== modified file 'openerp/modules/loading.py'
--- openerp/modules/loading.py 2012-07-11 08:42:21 +0000
+++ openerp/modules/loading.py 2012-07-11 08:42:21 +0000
@@ -293,6 +293,8 @@
#suppress commits to have the upgrade of one module in just one transation
cr.commit_org = cr.commit
cr.commit = lambda *args: None
+ cr.rollback_org = cr.rollback
+ cr.rollback = lambda *args: None
# register, instantiate and initialize models for each modules
for index, package in enumerate(graph):
=== modified file 'openerp/osv/orm.py'
--- openerp/osv/orm.py 2012-07-11 08:42:21 +0000
+++ openerp/osv/orm.py 2012-07-11 08:42:21 +0000
@@ -1415,11 +1415,14 @@
position = data.get(filename, 0)
while position<len(datas):
+ #use savepoints for opgenupgrade instead of transactions
+ cr.execute('SAVEPOINT process_lines');
(res, position, warning, res_id, xml_id) = \
process_liness(self, datas, [], current_module, self._name, fields_def, position=position)
if len(warning):
- cr.rollback()
+ cr.execute('ROLLBACK TO SAVEPOINT process_lines');
return -1, res, 'Line ' + str(position) +' : ' + '!\n'.join(warning), ''
+ cr.execute('RELEASE SAVEPOINT process_lines');
try:
ir_model_data_obj._update(cr, uid, self._name,
@@ -1450,6 +1453,8 @@
lng = context.get('lang', False) or 'en_US'
trans = self.pool.get('ir.translation')
error_msgs = []
+ #use savepoints for opgenupgrade instead of transactions
+ cr.execute('SAVEPOINT validate');
for constraint in self._constraints:
fun, msg, fields = constraint
if not fun(self, cr, uid, ids):
@@ -1469,9 +1474,10 @@
)
self._invalids.update(fields)
if error_msgs:
- cr.rollback()
+ cr.execute('ROLLBACK TO SAVEPOINT validate');
raise except_orm('ValidateError', '\n'.join(error_msgs))
else:
+ cr.execute('RELEASE SAVEPOINT validate');
self._invalids.clear()
def default_get(self, cr, uid, fields_list, context=None):
@@ -2957,6 +2963,7 @@
# add the NOT NULL constraint
cr.commit()
try:
+ #use savepoints for opgenupgrade instead of transactions
cr.execute('SAVEPOINT add_constraint');
cr.execute('ALTER TABLE "%s" ALTER COLUMN "%s" SET NOT NULL' % (self._table, k), log_exceptions=False)
cr.execute('RELEASE SAVEPOINT add_constraint');
@@ -3238,12 +3245,14 @@
sql_actions.sort(key=lambda x: x['order'])
for sql_action in [action for action in sql_actions if action['execute']]:
try:
+ #use savepoints for opgenupgrade instead of transactions
+ cr.execute('SAVEPOINT add_constraint2');
cr.execute(sql_action['query'])
- cr.commit()
+ cr.execute('RELEASE SAVEPOINT add_constraint2');
_schema.debug(sql_action['msg_ok'])
except:
_schema.warning(sql_action['msg_err'])
- cr.rollback()
+ cr.execute('ROLLBACK TO SAVEPOINT add_constraint2');
def _execute_sql(self, cr):
Follow ups