

def parse_form_value(self, v, obj):
    'Convert the form field value (expected to contain a primary key)\n        into the corresponding database object. If it is an invalid\n        primary key, return None.\n\n        If this comes from a *learning* ExtJS ComboBox\n        (i.e. :attr:`can_create_choice\n        <lino.core.choosers.Chooser.can_create_choice>` is True) the\n        value will be the text entered by the user. In that case, call\n        :meth:`create_choice\n        <lino.core.choosers.Chooser.create_choice>`.\n\n        '
    relto_model = self.get_rel_to(obj)
    if (not relto_model):
        return
    try:
        return relto_model.objects.get(pk=v)
    except ValueError:
        pass
    except relto_model.DoesNotExist:
        pass
    if (obj is not None):
        ch = obj.__class__.get_chooser_for_field(v.field.name)
        if (ch and ch.can_create_choice):
            return ch.create_choice(obj, v)
    return None

dataset/ETHPy150Open lsaffre/lino/lino/core/store.py ForeignKeyStoreField.parse_form_value/VarMisuse@89/307 `self`->`v`