diff options
| author | Victor Feyens <vfe@odoo.com> | 2020-02-24 11:08:21 +0000 |
|---|---|---|
| committer | Victor Feyens <vfe@odoo.com> | 2020-03-06 10:21:56 +0000 |
| commit | 623d6a066b4e3fee4e1a349870d5229c273a3ce5 (patch) | |
| tree | 52a5ade7330e0a9e29757559398801f27d28b6fa /addons/delivery/models | |
| parent | 20fec19fd0afc47bc8449e4ac70220aacb8ad03f (diff) | |
[FIX] delivery, sale: improve invoice_status performance.
* Avoid reading all lines invoice_status when the SO isn't confirmed.
* Do not use _default_product_id to discern down_payment lines, use is_downpayment instead
(one ref = one query less by compute call)
* Do not consider display_type lines for SO invoice_status.
X-original-commit: 76a6d0475872f9ffa21cb917f13bc553c720eafd
Diffstat (limited to 'addons/delivery/models')
| -rw-r--r-- | addons/delivery/models/sale_order.py | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/addons/delivery/models/sale_order.py b/addons/delivery/models/sale_order.py index 1d95abd4f1b..22dc8231345 100644 --- a/addons/delivery/models/sale_order.py +++ b/addons/delivery/models/sale_order.py @@ -127,6 +127,8 @@ class SaleOrder(models.Model): def _get_invoice_status(self): super()._get_invoice_status() for order in self: + if order.invoice_status in ['no', 'invoiced']: + continue order_lines = order.order_line.filtered(lambda x: not x.is_delivery and not x.is_downpayment and not x.display_type) if all(line.product_id.invoice_policy == 'delivery' and line.invoice_status == 'no' for line in order_lines): order.invoice_status = 'no' |
