Window functions are not append to select query for complex columns
The method _window_functions[1] checks if a column is a WindowFunction or Aggregate class. But it does not consider if there is a previous Cast(), or even if the column is a division and divisor is an Aggregate with Window.
[1] https://hg.tryton.org/python-sql/file/tip/sql/__init__.py#l508