[FIX] sale: speed up sale report
[FIX] sale: speed up sale report

Due to the row_number in the sale.report view, all queries using this
report were slowed down drastically as soon as there were a large amount
of sale.order.lines.

By using existing columns instead of computing new values at each query,
the queries execute in an acceptable time (even if the CASE statements
introduced by e7d8e26ae751 are still slowing down things a bit).

When there is no sale.order.line, min(l.id) would be NULL, so the
sale.order will be used instead. It is negated to avoid id conflicts.

However, note that addons/pos_sale/report/sale_report.py is not doing
anything to avoid conflicts between the ids of sale.order.line and
pos.order.line when doing its union.

closes odoo/odoo#53746

X-original-commit: 03bd6f5243e189cd05b3fc7ad774cc07ea733e14
Signed-off-by: Yannick Tivisse (yti) <200a91eb0e5cc4726d6a3430713b580138f34298@odoo.com>
Signed-off-by: Paul Morelle <4950c5a1ead41dfa3dcc3f68ece6c9007ac6ccce@users.noreply.github.com>

ygol/odoo,ygol/odoo,ygol/odoo,ygol/odoo,ygol/odoo,ygol/odoo,ygol/odoo