[FIX] sale: invoice count on SO: only take inv on same company
Before this commit, the smart button on the SO was computed with only the SO's name field In a multicompany setting, it could give up invoices from other companies After this commit, only the invoices of the same company as the order are accounted for OPW 1831551 closes #23925
This commit is contained in:
@@ -59,7 +59,7 @@ class SaleOrder(models.Model):
|
||||
# Search for invoices which have been 'cancelled' (filter_refund = 'modify' in
|
||||
# 'account.invoice.refund')
|
||||
# use like as origin may contains multiple references (e.g. 'SO01, SO02')
|
||||
refunds = invoice_ids.search([('origin', 'like', order.name)]).filtered(lambda r: r.type in ['out_invoice', 'out_refund'])
|
||||
refunds = invoice_ids.search([('origin', 'like', order.name), ('company_id', '=', order.company_id.id)]).filtered(lambda r: r.type in ['out_invoice', 'out_refund'])
|
||||
invoice_ids |= refunds.filtered(lambda r: order.name in [origin.strip() for origin in r.origin.split(',')])
|
||||
# Search for refunds as well
|
||||
refund_ids = self.env['account.invoice'].browse()
|
||||
|
||||
Reference in New Issue
Block a user