[FIX] sale: speed-up invoice creation
[FIX] sale: speed-up invoice creation

  - At invoice creation, the stored fields that depends on `invoice_lines`
    are computed to be stored.
    This can slow down the invoice creation for a database with a lot of
    records on `account_move`.

    This commit speed-up the invoice creation by using SQL Joins to
    speed-up the searches.
    We cannot use `auto_join` on the `invoice_lines` field since it is
    not supported on many2many, thus we do it in SQL.

closes odoo/odoo#46233

X-original-commit: b39e17c464775564faa7d0f10e675d47fa026234
Signed-off-by: Toufik Benjaa (tbe) <c6f81aa4457266a65463c97406f59c8b81e8d7de@odoo.com>

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