[fix] for some addons, multiple toplevel menus with the same name are created, generating a single ir.ui.menu entry but multiple ir.model.data for the (ir.ui.menu, @id) specified. Ensure that we remove all ir.model.data matching a given ir.ui.menu, not just a random one or upgrade fails when we try to go from the leftover ir.model.data to the (now missing) ir.ui.menu
lp bug: https://launchpad.net/bugs/530835 fixed bzr revid: xmo@tinyerp.com-20100303154041-37hzymi7e5ur9yb6
This commit is contained in:
parent
948e89992f
commit
ca39947d11
|
@ -18,7 +18,8 @@
|
||||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
#
|
#
|
||||||
##############################################################################
|
##############################################################################
|
||||||
|
import logging
|
||||||
|
from operator import itemgetter
|
||||||
from osv import fields,osv
|
from osv import fields,osv
|
||||||
import ir, re
|
import ir, re
|
||||||
import netsvc
|
import netsvc
|
||||||
|
@ -417,6 +418,7 @@ ir_model_access()
|
||||||
|
|
||||||
class ir_model_data(osv.osv):
|
class ir_model_data(osv.osv):
|
||||||
_name = 'ir.model.data'
|
_name = 'ir.model.data'
|
||||||
|
__logger = logging.getLogger('addons.base.'+_name)
|
||||||
_columns = {
|
_columns = {
|
||||||
'name': fields.char('XML Identifier', required=True, size=128),
|
'name': fields.char('XML Identifier', required=True, size=128),
|
||||||
'model': fields.char('Object', required=True, size=64),
|
'model': fields.char('Object', required=True, size=64),
|
||||||
|
@ -599,22 +601,37 @@ class ir_model_data(osv.osv):
|
||||||
wf_service.trg_write(uid, model, id, cr)
|
wf_service.trg_write(uid, model, id, cr)
|
||||||
|
|
||||||
cr.commit()
|
cr.commit()
|
||||||
if not config.get('import_partial', False):
|
if not config.get('import_partial'):
|
||||||
logger = netsvc.Logger()
|
|
||||||
for (model, res_id) in self.unlink_mark.keys():
|
for (model, res_id) in self.unlink_mark.keys():
|
||||||
if self.pool.get(model):
|
if self.pool.get(model):
|
||||||
logger.notifyChannel('init', netsvc.LOG_INFO, 'Deleting %s@%s' % (res_id, model))
|
self.__logger.info('Deleting %s@%s', res_id, model)
|
||||||
try:
|
try:
|
||||||
self.pool.get(model).unlink(cr, uid, [res_id])
|
self.pool.get(model).unlink(cr, uid, [res_id])
|
||||||
id = self.unlink_mark[(model, res_id)]
|
|
||||||
if id:
|
if id:
|
||||||
self.unlink(cr, uid, [id])
|
ids = self.search(cr, uid, [('res_id','=',res_id),
|
||||||
cr.execute('DELETE FROM ir_values WHERE value=%s', ('%s,%s' % (model, res_id),))
|
('model','=',model)])
|
||||||
|
self.__logger.debug('=> Deleting %s: %s',
|
||||||
|
self._name, ids)
|
||||||
|
if len(ids) > 1 and \
|
||||||
|
self.__logger.isEnabledFor(logging.WARNING):
|
||||||
|
self.__logger.warn(
|
||||||
|
'Got %d %s for (%s, %d): %s',
|
||||||
|
len(ids), self._name, model, res_id,
|
||||||
|
map(itemgetter('module','name'),
|
||||||
|
self.read(cr, uid, ids,
|
||||||
|
['name', 'module'])))
|
||||||
|
self.unlink(cr, uid, ids)
|
||||||
|
cr.execute(
|
||||||
|
'DELETE FROM ir_values WHERE value=%s',
|
||||||
|
('%s,%s'%(model, res_id),))
|
||||||
cr.commit()
|
cr.commit()
|
||||||
except Exception, e:
|
except Exception:
|
||||||
cr.rollback()
|
cr.rollback()
|
||||||
logger.notifyChannel('init', netsvc.LOG_ERROR, e)
|
self.__logger.exception(
|
||||||
logger.notifyChannel('init', netsvc.LOG_ERROR, 'Could not delete id: %d of model %s\nThere should be some relation that points to this resource\nYou should manually fix this and restart --update=module' % (res_id, model))
|
'Could not delete id: %d of model %s\nThere '
|
||||||
|
'should be some relation that points to this '
|
||||||
|
'resource\nYou should manually fix this and '
|
||||||
|
'restart with --update=module', res_id, model)
|
||||||
return True
|
return True
|
||||||
ir_model_data()
|
ir_model_data()
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue