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
```
order_by_elements.append("%s %s" % (qualifield_name, order_direction))
                else:
                    continue  
        return order_by_elements
    @api.model
    def _generate_order_by(self, order_spec, query):
        """
        Attempt to construct an appropriate ORDER BY clause based on order_spec, which must be
        a comma-separated list of valid field names, optionally followed by an ASC or DESC direction.
        :raise ValueError in case order_spec is malformed
        """
        order_by_clause = ''
        order_spec = order_spec or self._order
        if order_spec:
            order_by_elements = self._generate_order_by_inner(self._table, order_spec, query)
            if order_by_elements:
                order_by_clause = ",".join(order_by_elements)
        return order_by_clause and (' ORDER BY %s ' % order_by_clause) or ''
    @api.model
    def _search(self, args, offset=0, limit=None, order=None, count=False, access_rights_uid=None):
        """
        Private implementation of search() method, allowing specifying the uid to use for the access right check.
        This is useful for example when filling in the selection list for a drop-down and avoiding access rights errors,
        by specifying ``access_rights_uid=1`` to bypass access rights check, but not ir.rules!
        This is ok at the security level because this method is private and not callable through XML-RPC.
        :param access_rights_uid: optional user ID to use when checking access rights
                                  (not for ir.rules, this is only for ir.model.access)
        :return: a list of record ids or an integer (if count is True)
        """
        self.sudo(access_rights_uid or self._uid).check_access_rights('read')