'Check whether the fields in ``self`` may be modified or removed.
This method prevents the modification/deletion of many2one fields
that have an inverse one2many, for instance.'

@api.multi
def _prepare_update(self):

    self = self.filtered((lambda record: (record.state == 'manual')))
    if (not self):
        return
    for record in self:
        model = self.env[record.model]
        field = model._fields[record.name]
        if ((field.type == 'many2one') and model._field_inverses.get(field)):
            if self._context.get(MODULE_UNINSTALL_FLAG):
                inverses = self.search([('relation', '=', field.model_name), ('relation_field', '=', field.name)])
                inverses.unlink()
                continue
            msg = _("The    field    '%s'    cannot    be    removed    because    the    field    '%s'    depends    on    it.")
            raise UserError((msg % (field, model._field_inverses[field][0])))
    fields = [self.env[record.model]._pop_field(record.name) for record in self]
    domain = expression.OR(([('arch_db', 'like', record.name)] for record in self))
    views = self.env['ir.ui.view'].search(domain)
    try:
        for view in views:
            view._check_xml()
    except Exception:
        raise UserError('\n'.join([_('Cannot    rename/delete    fields    that    are    still    present    in    views:'), ((_('Fields:') + '    ') + ',    '.join(map(str, fields))), ((_('View:') + '    ') + view.name)]))
    finally:
        self.pool.setup_models(self._cr)
