[FIX] sale: search on invoice_ids
some fields may depend on invoice_ids, which lead to a perf issue when field is not searchable. closes odoo/odoo#42950 X-original-commit: 53f363269c21eb6b2615d660f1c558c5a592e04b Signed-off-by: Christophe Simonis <chs@odoo.com>
This commit is contained in:
@@ -116,6 +116,9 @@ class SaleOrder(models.Model):
|
||||
self.ensure_one()
|
||||
return 'form'
|
||||
|
||||
def _search_invoice_ids(self, operator, value):
|
||||
return ['&', ('order_line.invoice_lines.move_id.type', 'in', ('out_invoice', 'out_refund')), ('order_line.invoice_lines.move_id', operator, value)]
|
||||
|
||||
name = fields.Char(string='Order Reference', required=True, copy=False, readonly=True, states={'draft': [('readonly', False)]}, index=True, default=lambda self: _('New'))
|
||||
origin = fields.Char(string='Source Document', help="Reference of the document that generated this sales order request.")
|
||||
client_order_ref = fields.Char(string='Customer Reference', copy=False)
|
||||
@@ -175,7 +178,7 @@ class SaleOrder(models.Model):
|
||||
order_line = fields.One2many('sale.order.line', 'order_id', string='Order Lines', states={'cancel': [('readonly', True)], 'done': [('readonly', True)]}, copy=True, auto_join=True)
|
||||
|
||||
invoice_count = fields.Integer(string='Invoice Count', compute='_get_invoiced', readonly=True)
|
||||
invoice_ids = fields.Many2many("account.move", string='Invoices', compute="_get_invoiced", readonly=True, copy=False)
|
||||
invoice_ids = fields.Many2many("account.move", string='Invoices', compute="_get_invoiced", readonly=True, copy=False, search="_search_invoice_ids")
|
||||
invoice_status = fields.Selection([
|
||||
('upselling', 'Upselling Opportunity'),
|
||||
('invoiced', 'Fully Invoiced'),
|
||||
|
||||
Reference in New Issue
Block a user