'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'

@api.model
def _generate_order_by(self, order_spec, query):

    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 '')
