'the M2O field conversion (from html) is markedly different from
others as it directly writes into the m2o and returns nothing at all.'

def test_m2o(self):

    field = 'many2one'
    subrec1 = self.env['web_editor.converter.test.sub'].create({'name': 'Foo'})
    subrec2 = self.env['web_editor.converter.test.sub'].create({'name': 'Bar'})
    record = self.env['web_editor.converter.test'].create({field: subrec1.id})
    t = etree.Element('t')
    e = etree.Element('span')
    t.append(e)
    field_value = ('record.%s' % field)
    e.set('t-field', field_value)
    rendered = self.env['ir.qweb'].render(t, {'record': record})
    element = html.fromstring(rendered, parser=html.HTMLParser(encoding='utf-8'))
    element.set('data-oe-many2one-id', str(subrec2.id))
    element.text = 'New    content'
    model = ('ir.qweb.field.' + element.get('data-oe-type'))
    converter = (self.env[model] if (model in self.env) else self.env['ir.qweb.field'])
    value_back = converter.from_html('web_editor.converter.test', record._fields[field], element)
    self.assertIsNone(value_back, 'the    m2o    converter    should    return    None    to    avoid    spurious    or    useless    writes    on    the    parent    record')
    self.assertEqual(subrec1.name, 'Foo', "element    edition    can't    change    directly    the    m2o    record")
    self.assertEqual(record.many2one.name, 'Bar', 'element    edition    should    have    been    change    the    m2o    id')
