# -*- coding: utf-8 -*-
##############################################################################
#
#    Author: Guewen Baconnier
#    Copyright 2012-2013 Camptocamp SA
#    Copyright 2015 anybox SA
#
#    This program is free software: you can redistribute it and/or modify
#    it under the terms of the GNU Affero General Public License as
#    published by the Free Software Foundation, either version 3 of the
#    License, or (at your option) any later version.
#
#    This program is distributed in the hope that it will be useful,
#    but WITHOUT ANY WARRANTY; without even the implied warranty of
#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#    GNU Affero General Public License for more details.
#
#    You should have received a copy of the GNU Affero General Public License
#    along with this program.  If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################

from openerp import models
from openerp.tools.cache import ormcache


class IrModuleModule(models.Model):
    _inherit = 'ir.module.module'

    @ormcache(skiparg=1)
    def is_module_installed(self, module_name):
        return bool(len(self.env['ir.module.module'].search([
            ('name', '=', module_name),
            ('state', '=', 'installed')])))

    def state_update(self, *args, **kwargs):
        res = super(IrModuleModule, self).state_update(*args, **kwargs)
        self.clear_caches()
        return res

@@ -1072,16 +1072,383 @@
 Model):%0A
+    %22%22%22Overwrite ir.module.module to add cached method 'is_module_installed'.%0A    This method is cached, because connector will always check if a module is%0A    installed before do action.%0A%0A    The next methods change the state of the module, then they must invalidate%0A    the cache of 'is_module_installed' method:%0A%0A    * state_update%0A    * module_uninstall%0A%0A    %22%22%22%0A
     _inh
@@ -1858,8 +1858,181 @@
 urn res%0A
+%0A    def module_uninstall(self, *args, **kwargs):%0A        res = super(IrModuleModule, self).module_uninstall(*args, **kwargs)%0A        self.clear_caches()%0A        return res%0A

Fix, the method 'module_uninstall' invalid the ormcache of is_module_installed