**Impacted versions:**

Found in 9.0, reproduced in 9.0 and 11.0, I assume it happens on 10.0 as well.

**Steps to reproduce:**

The situation happens when you have a base addon declaring a Many2one field without index, another addon which adds an index to the field by extending it, then a third addon that extend the same model (no matter what it does). The second and third addon do not have any dependency between them.

Base addon:
```
class ResPartner(models.Model):
    _name = 'res.partner'

    country_id = fields.Many2one('res.country')
```
Addon adding the index, depends on 'base'
```
class ResPartner(models.Model):
    _inherit = 'res.partner'

    country_id = fields.Many2one(index=True)
```
Addon doing something else on res.partner
```
class ResPartner(models.Model):
    _inherit = 'res.partner'

    my_field = fields.Char()
```

Once all 3 addons are installed, there should be an index on `res_partner.country_id`. Now if an upgrade of the third addon is done, the index is dropped.

It can be reproduced with the code from this repository: https://github.com/guewen/odoo-issues-reproduct/tree/issue-index-drop-on-update

1. Install the addons

```
odoo --workers=0 --stop-after-init -i addon1,addon2
```

2. Check presence of the index

```
$ psql
# \d res_partner
Indexes:
    ...
    "res_partner_country_id_index" btree (country_id)
```
3. Upgrade `addon1`

```
odoo --workers=0 --stop-after-init -u addon1
```

4. Check again the presence of the index

**Current behavior:**

The index is lost when an upgrade of the addon is done, as soon as there is an inherit of the same model and no dependency between the addons (addon1 and addon2).
It is because during the upgrade, when it reaches [this line](https://github.com/odoo/odoo/blob/12b11c1e6fe179abf988b1ff8c812fad08295215/odoo/fields.py#L900), the field is not yet flagged as `index=True`, because the other addon is not loaded yet. It probably depends of the order of loading then.

This is a dangerous behavior because it can go unnoticed. You add `index=True` in some addon, which get added properly, and suddenly removed when, later, you update (or install I guess) another addon.

**Expected behavior:**

The index is not dropped.



t0 = time.time()
    t0_sql = openerp.sql_db.sql_counter
    for index, package in enumerate(graph):
        module_name = package.name
        module_id = package.id
        if skip_modules and module_name in skip_modules:
            continue
        migrations.migrate_module(package, 'pre')
        load_openerp_module(package.name)
        new_install = package.state == 'to install'
        if new_install:
            py_module = sys.modules['openerp.addons.%s' % (module_name,)]
            pre_init = package.info.get('pre_init_hook')
            if pre_init:
                getattr(py_module, pre_init)(cr)
        models = registry.load(cr, package)
        loaded_modules.append(package.name)
        if hasattr(package, 'init') or hasattr(package, 'update') or package.state in ('to install', 'to upgrade'):
            registry.setup_models(cr, partial=True)
            init_module_models(cr, package.name, models)
        idref = {}
        mode = 'update'
        if hasattr(package, 'init') or package.state == 'to install':
            mode = 'init'
        if hasattr(package, 'init') or hasattr(package, 'update') or package.state in ('to install', 'to upgrade'):
            
            
            modobj = registry['ir.module.module']
            if perform_checks:
                modobj.check(cr, SUPERUSER_ID, [module_id])