@classmethod
def create(cls, store, plugin_name):
    """Add a valid InstalledPlugin into the database

        This method sets plugin_version to 0 if a there is a Pre-Installed
        Plugin on the database, or creates a InstalledPlugin with
        plugin_version set to 0 if None is available.
        """
    from stoqlib.lib.pluginmanager import PluginError
    plugin = store.find(cls, plugin_name=plugin_name).one()
    if plugin is None:
        return cls(store=store, plugin_name=plugin_name, plugin_version=0)
    if plugin.plugin_version is None:
        plugin.plugin_version = 0
        return plugin
    raise PluginError('Plugin %s is already installed.' % (plugin_name,))
