'The purpose of the method is to define a domain for the available
purchase orders.'

@api.onchange('state', 'partner_id', 'invoice_line_ids')
def _onchange_allowed_purchase_ids(self):

    result = {}
    purchase_line_ids = self.invoice_line_ids.mapped('purchase_line_id')
    purchase_ids = self.invoice_line_ids.mapped('purchase_id').filtered((lambda r: (r.order_line <= purchase_line_ids)))
    result['domain'] = {'purchase_id': [('invoice_status', '=', 'to    invoice'), ('partner_id', 'child_of', self.partner_id.id), ('id', 'not    in', purchase_ids.ids)]}
    return result
