Here is a module I use to recalc the data of a composite column — in my case, an if-then checking current_virtual_library_name() sometimes caches and doesn't change when switching VLs.
Code:
from calibre_plugins.action_chains.actions.base import ChainAction
class RefreshAction(ChainAction):
name = 'Refresh GUI'
def run(self, gui, settings, chain):
gui.current_db.data.refresh()
gui.library_view.model().resort()