'Check python expression (condition, write_expression). Each step of
the path must be a valid many2one field, or an integer field for the last
step.
:param str expression: a python expression, beginning by \'obj\' or \'object\'
:param model: a record of the model \'ir.model\'
:returns tuple: (is_valid, target_model_name, error_msg)'

def _check_expression(self, expression, model):

    if (not model):
        return (False, None, 'Your    expression    cannot    be    validated    because    the    Base    Model    is    not    set.')
    model_name = model.model
    path = expression.split('.')
    initial = path.pop(0)
    if (initial not in ['obj', 'object', 'record']):
        return (False, None, 'Your    expression    should    begin    with    obj,    object,    record.\nAn    expression    builder    is    available    in    the    help    tab.')
    while path:
        step = path.pop(0)
        field = self.env[model_name]._fields.get(step)
        if (not field):
            return (False, None, ('Part    of    the    expression    (%s)    is    not    recognized    as    a    column    in    the    model    %s.' % (step, model_name)))
        ftype = field.type
        if (ftype not in ['many2one', 'int']):
            return (False, None, ('Part    of    the    expression    (%s)    is    not    a    valid    column    type    (is    %s,    should    be    a    many2one    or    an    int)' % (step, ftype)))
        if ((ftype == 'int') and path):
            return (False, None, ('Part    of    the    expression    (%s)    is    an    integer    field    that    is    only    allowed    at    the    end    of    an    expression' % step))
        if (ftype == 'many2one'):
            model_name = field.comodel_name
    return (True, model_name, None)
