On large recordsets I got some severe performance issues while browsing through an inherits relation.
For example I have a batch process exporting a csv file with products variants:

I have to export 50.000 products.

If I do :
`variant.categ_id` It takes a very long time to get the result.

If I do:
`variant.product_tmpl_id.categ_id` The result is immediate

The problem is that the global perfomance of the application is impacted by this problem.

For example my POS takes more than 15 minutes to load. Because I have 26.000 products and the compute price method uses a lot browsing through the inherits such like `product.cated_id`, `product.uom_id` and they all takes a huge time to compute.

Same issue in this case.

If I do :
`variant.price` It takes a very long time to get the result.

If I do:
`variant.product_tmpl_id.price` The result is immediate

Could you help me ?


Simple way to reproduce:

1/ Create a new database and install sale module
2/ Launch following script through odoo shell :

```python
# -*- coding: utf-8 -*-
import logging

_logger = logging.getLogger(__name__)
self = self  # noqa

nb_product = 50000

i = 0
while i < nb_product:
    prod = self.env['product.template'].create({'name': 'product_%s' % i})
    i += 1
    if i % 1000 == 0:
        self.env.cr.commit()
        _logger.info("%s Products Created" % i)
```

2/ Launch following script through odoo shell :
```python
# -*- coding: utf-8 -*-
import logging

_logger = logging.getLogger(__name__)
self = self  # noqa


products = self.env['product.product'].search([])

for product in products:
    # Immediate response
    _logger.info('Category Template %s' % product.product_tmpl_id.categ_id)
    # Lagging response
    _logger.info('Category Variant %s' % product.categ_id) 
    break
```
odoo/models.py
assert self.is_transient() or not dest_model.is_transient(), \
            'Many2One relationships from non-transient Model to TransientModel are forbidden'
        if self.is_transient() and not dest_model.is_transient():
            
            
            
            ondelete = ondelete or 'cascade'
        field = self._fields[source_field]
        self._m2o_add_foreign_key_unchecked(self._table, source_field, dest_model, ondelete, field._module)
    
    def _m2o_add_foreign_key_unchecked(self, source_table, source_field, dest_model, ondelete, module):
        fk_def = (source_table, source_field, dest_model._table, ondelete or 'set null', module)
        self._foreign_keys.add(fk_def)
        _schema.debug("Table '%s': added foreign key '%s' with definition=REFERENCES \"%s\" ON DELETE %s", *fk_def[:-1])
    @api.model_cr
    def _m2o_fix_foreign_key(self, source_table, source_field, dest_model, ondelete):
        
        
        query = """ SELECT confdeltype as ondelete_rule, conname as constraint_name,
                           cl2.relname as foreign_table
                      FROM pg_constraint as con, pg_class as cl1, pg_class as cl2,
                           pg_attribute as att1, pg_attribute as att2
                     WHERE con.conrelid = cl1.oid
                       AND cl1.relname = %s
                       AND con.confrelid = cl2.oid
                       AND array_lower(con.conkey, 1) = 1
                       AND con.conkey[1] = att1.attnum
                       AND att1.attrelid = cl1.oid
                       AND att1.attname = %s