Q:

Conditions in modeler field calculator

I want to check a vector file if there is a column "Source". 
If yes, nothing to do. If there is no column "Source" it should be created and filled up with '0'. 
Is this possible to do via the modeler?

A:

Create a new script from:
Processing Toolbox > Scripts > Tools > Create new script

Use something like the following:
##Example=name
##Layer=vector

from qgis.core import QgsField
from PyQt4.QtCore import QVariant

layer = processing.getObject(Layer)
idx = layer.fieldNameIndex('Source')

if idx != -1:
    pass
else:
    layer.startEditing()
    layer.dataProvider().addAttributes( [ QgsField("Source", QVariant.Int) ] )
    layer.updateFields()
    for feat in layer.getFeatures():
        layer.changeAttributeValue(feat.id(), layer.fieldNameIndex('Source'), '0')
    layer.commitChanges()

Save the script in your C:/Users/You/.qgis2/processing/scripts/ directory. Then you should be able to call this script in your modeler.

